60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
use Spatie\Activitylog\LogOptions;
|
||
|
|
use Spatie\Activitylog\Traits\LogsActivity;
|
||
|
|
|
||
|
|
class ClientContact extends Model
|
||
|
|
{
|
||
|
|
/** @use HasFactory<\Database\Factories\ClientContactFactory> */
|
||
|
|
use HasFactory, LogsActivity;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The attributes that are mass assignable.
|
||
|
|
*
|
||
|
|
* @var list<string>
|
||
|
|
*/
|
||
|
|
protected $fillable = [
|
||
|
|
'client_id',
|
||
|
|
'full_name',
|
||
|
|
'job_title',
|
||
|
|
'email',
|
||
|
|
'phone',
|
||
|
|
'is_principal',
|
||
|
|
];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the attributes that should be cast.
|
||
|
|
*
|
||
|
|
* @return array<string, string>
|
||
|
|
*/
|
||
|
|
protected function casts(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'is_principal' => 'boolean',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the client that owns the contact.
|
||
|
|
*
|
||
|
|
* @return BelongsTo<Client, $this>
|
||
|
|
*/
|
||
|
|
public function client(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Client::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getActivitylogOptions(): LogOptions
|
||
|
|
{
|
||
|
|
return LogOptions::defaults()
|
||
|
|
->logFillable()
|
||
|
|
->logOnlyDirty()
|
||
|
|
->dontSubmitEmptyLogs();
|
||
|
|
}
|
||
|
|
}
|