Total Complexity | 6 |
Total Lines | 70 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
22 | class HrAdvisor extends BaseModel |
||
23 | { |
||
24 | /** |
||
25 | * @var string[] $casts |
||
26 | */ |
||
27 | protected $casts = [ |
||
28 | 'department_id' => 'int', |
||
29 | 'user_id' => 'int' |
||
30 | ]; |
||
31 | |||
32 | /** |
||
33 | * The attributes that should be visible in arrays. |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $visible = ['id', 'department_id', 'user_id', 'name', 'claimed_job_ids']; |
||
38 | |||
39 | /** |
||
40 | * @var string[] $fillable |
||
41 | */ |
||
42 | protected $fillable = ['department_id']; |
||
43 | |||
44 | |||
45 | |||
46 | /** |
||
47 | * The accessors to append to the model's array form. |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $appends = ['name', 'claimed_job_ids']; |
||
52 | |||
53 | public function user() |
||
2 ignored issues
–
show
|
|||
54 | { |
||
55 | return $this->belongsTo(\App\Models\User::class); |
||
56 | } |
||
57 | |||
58 | public function department() |
||
2 ignored issues
–
show
|
|||
59 | { |
||
60 | return $this->belongsTo(\App\Models\Lookup\Department::class); |
||
61 | } |
||
62 | |||
63 | public function claimed_jobs() |
||
2 ignored issues
–
show
|
|||
64 | { |
||
65 | return $this->belongsToMany( |
||
66 | \App\Models\JobPoster::class, |
||
67 | 'claimed_jobs' |
||
68 | ); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Return the full name of the User associated with this HR Advisor. |
||
73 | * |
||
74 | * @return string |
||
1 ignored issue
–
show
|
|||
75 | */ |
||
76 | public function getNameAttribute(): string |
||
77 | { |
||
78 | if ($this->user !== null) { |
||
79 | return $this->user->first_name . ' ' . $this->user->last_name; |
||
80 | } |
||
81 | return ''; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Return an array of ids of claimed jobs. |
||
86 | * |
||
87 | * @return array |
||
88 | */ |
||
89 | public function getClaimedJobIdsAttribute() |
||
92 | } |
||
93 | } |
||
94 |