Passed
Push — feature/redux-claim-job ( b0411b )
by Tristan
11:52
created

HrAdvisor::claimed_jobs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Models;
4
5
/**
6
 * Class HrAdvisor
7
 *
8
 * @property int $id
9
 * @property int $user_id
10
 * @property int $department_id
11
 *
12
 * @property \App\Models\User $user
13
 * @property \App\Models\Lookup\Department $department
14
 * @property \Illuminate\Database\Eloquent\Collection $job_posters
15
 * @property \Jenssegers\Date\Date $created_at
16
 * @property \Jenssegers\Date\Date $updated_at
17
 *
18
 * Computed Properties
19
 * @property string $name
20
 */
21
class HrAdvisor extends BaseModel
22
{
23
    /**
24
     * @var string[] $casts
25
     */
26
    protected $casts = [
27
        'department_id' => 'int',
28
        'user_id' => 'int'
29
    ];
30
31
    /**
32
     * @var string[] $fillable
33
     */
34
    protected $fillable = ['department_id'];
35
36
    public function user()
2 ignored issues
show
introduced by
Method \App\Models\HrAdvisor::user() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function user()
Loading history...
37
    {
38
        return $this->belongsTo(\App\Models\User::class);
39
    }
40
41
    public function department()
2 ignored issues
show
introduced by
Method \App\Models\HrAdvisor::department() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function department()
Loading history...
42
    {
43
        return $this->belongsTo(\App\Models\Lookup\Department::class);
44
    }
45
46
    public function claimed_jobs() //phpcs:ignore
47
    {
48
        return $this->belongsToMany(
49
            \App\Models\JobPoster::class,
50
            'claimed_jobs'
51
        );
52
    }
53
54
    /**
55
     * Return the full name of the User associated with this HR Advisor.
56
     *
57
     * @return string
1 ignored issue
show
introduced by
Method \App\Models\HrAdvisor::getNameAttribute() has useless @return annotation.
Loading history...
58
     */
59
    public function getNameAttribute(): string
60
    {
61
        if ($this->user !== null) {
62
            return $this->user->first_name . ' ' . $this->user->last_name;
63
        }
64
        return '';
65
    }
66
}
67