1 | <?php |
||
2 | |||
3 | namespace App\Models; |
||
4 | |||
5 | use Backpack\CRUD\app\Models\Traits\CrudTrait; |
||
6 | use Illuminate\Database\Eloquent\Model; |
||
7 | use Spatie\Activitylog\Traits\LogsActivity; |
||
8 | |||
9 | /** |
||
10 | * @mixin IdeHelperContact |
||
11 | */ |
||
12 | class Contact extends Model |
||
13 | { |
||
14 | use CrudTrait; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
15 | use LogsActivity; |
||
16 | |||
17 | protected $fillable = ['firstname', 'lastname', 'idnumber', 'address', 'email', 'relationship_id', 'profession_id', 'student_id']; |
||
18 | |||
19 | protected $with = ['phone', 'relationship', 'profession']; |
||
20 | |||
21 | protected $appends = ['name']; |
||
22 | |||
23 | protected static bool $logUnguarded = true; |
||
24 | |||
25 | public function phone() |
||
26 | { |
||
27 | return $this->morphMany(PhoneNumber::class, 'phoneable'); |
||
28 | } |
||
29 | |||
30 | public function getNameAttribute() |
||
31 | { |
||
32 | return $this->firstname.' '.$this->lastname; |
||
33 | } |
||
34 | |||
35 | public function student() |
||
36 | { |
||
37 | return $this->belongsTo(Student::class); |
||
38 | } |
||
39 | |||
40 | public function relationship() |
||
41 | { |
||
42 | return $this->belongsTo(ContactRelationship::class); |
||
43 | } |
||
44 | |||
45 | public function profession() |
||
46 | { |
||
47 | return $this->belongsTo(Profession::class); |
||
48 | } |
||
49 | } |
||
50 |