2025-10-29 17:17:50 +03:00

45 lines
851 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Contact extends Model
{
protected $fillable = [
'first_name',
'last_name',
'email',
'phone',
'mobile',
'position',
'notes',
'is_primary',
'client_id',
'fournisseur_id'
];
protected $casts = [
'is_primary' => 'boolean',
];
public function client(): BelongsTo
{
return $this->belongsTo(Client::class);
}
public function fournisseur(): BelongsTo
{
return $this->belongsTo(Fournisseur::class);
}
/**
* Get the contact's full name.
*/
public function getFullNameAttribute(): string
{
return trim("{$this->first_name} {$this->last_name}");
}
}