User::grantedRecruitments()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\SoftDeletes;
6
use Illuminate\Foundation\Auth\User as Authenticatable;
7
use Illuminate\Notifications\Notifiable;
8
use Laravel\Passport\HasApiTokens;
9
use Spatie\Permission\Traits\HasRoles;
10
11
class User extends Authenticatable
12
{
13
    use HasRoles;
0 ignored issues
show
introduced by
The trait Spatie\Permission\Traits\HasRoles requires some properties which are not provided by App\Models\User: $name, $map, $permissions, $roles, $guard_name
Loading history...
14
    use HasApiTokens;
15
    use Notifiable;
0 ignored issues
show
Bug introduced by
The trait Illuminate\Notifications\Notifiable requires the property $email which is not provided by App\Models\User.
Loading history...
16
    use SoftDeletes;
17
18
    protected $connection = 'tenant';
19
20
    /**
21
     * The attributes that are mass assignable.
22
     *
23
     * @var array
24
     */
25
    protected $fillable = [
26
        'name', 'email', 'password',
27
    ];
28
29
    /**
30
     * The attributes that should be hidden for arrays.
31
     *
32
     * @var array
33
     */
34
    protected $hidden = [
35
        'password', 'remember_token',
36
    ];
37
38
    /**
39
     * The attributes that should be cast to native types.
40
     *
41
     * @var array
42
     */
43
    protected $casts = [
44
        'email_verified_at' => 'datetime',
45
    ];
46
47
    /**
48
     * Find the user instance for the given username.
49
     *
50
     * @param string $username
51
     *
52
     * @return User
53
     */
54
    public function findForPassport($username)
55
    {
56
        return $this->where('email', $username)->where('pending_invitation', 0)->first();
57
    }
58
59
    /**
60
     * Used to determine access rights if a user has limited role.
61
     *
62
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
63
     */
64
    public function grantedRecruitments()
65
    {
66
        return $this->belongsToMany(Recruitment::class)->withTimestamps();
67
    }
68
}
69