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