Passed
Push — develop ( 25481c...ab4837 )
by Ngoding
04:42
created

User::isManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace App\Models;
4
5
use App\Infrastructure\Auth\Notifications\ResetPasswordQueued;
6
use App\Infrastructure\Auth\Notifications\VerifyEmailQueued;
7
use App\Infrastructure\Contracts\Auth\HasRole;
8
use App\Infrastructure\Contracts\Auth\MustVerifyEmail;
9
use App\Infrastructure\Foundation\Auth\User as Authenticatable;
10
use Illuminate\Database\Eloquent\Factories\HasFactory;
11
use Illuminate\Notifications\Notifiable;
12
use Laravel\Sanctum\HasApiTokens;
13
14
/**
15
 * @method static \Database\Factories\UserFactory<static> factory(callable|array|int|null $count = null, callable|array $state = []) Get a new factory instance for the model.
16
 */
17
class User extends Authenticatable implements HasRole, MustVerifyEmail
18
{
19
    use HasApiTokens, HasFactory, Notifiable,
0 ignored issues
show
Bug introduced by
The trait App\Models\Concerns\User\Event requires the property $map which is not provided by App\Models\User.
Loading history...
introduced by
The trait App\Models\Concerns\User\Relation requires some properties which are not provided by App\Models\User: $permissions, $guard_name
Loading history...
20
        Concerns\User\Attribute,
21
        Concerns\User\Event,
22
        Concerns\User\Relation;
23
24
    /**
25
     * {@inheritDoc}
26
     *
27
     * @var array<int, string>
28
     */
29
    protected $fillable = [
30
        'username',
31
        'name',
32
        'email',
33
        'password',
34
    ];
35
36
    /**
37
     * {@inheritDoc}
38
     *
39
     * @var array<int, string>
40
     */
41
    protected $hidden = [
42
        'password',
43
        'remember_token',
44
    ];
45
46
    /**
47
     * {@inheritDoc}
48
     *
49
     * @var array<string, string>
50
     */
51
    protected $casts = [
52
        'email_verified_at' => 'datetime',
53
    ];
54
55
    /**
56
     * {@inheritDoc}
57
     */
58 1
    public function sendEmailVerificationNotification()
59
    {
60 1
        $this->notify(new VerifyEmailQueued);
61
    }
62
63
    /**
64
     * {@inheritDoc}
65
     */
66 3
    public function sendPasswordResetNotification($token)
67
    {
68 3
        $this->notify(new ResetPasswordQueued($token));
69
    }
70
71
    /**
72
     * {@inheritDoc}
73
     */
74 1
    public function isAdmin(): bool
75
    {
76 1
        return $this->hasRole(Role::ROLE_ADMIN);
77
    }
78
79
    /**
80
     * {@inheritDoc}
81
     */
82
    public function isManager(): bool
83
    {
84
        return $this->hasRole(Role::ROLE_MANAGER);
85
    }
86
87
    /**
88
     * {@inheritDoc}
89
     */
90
    public function isStaff(): bool
91
    {
92
        return $this->hasRole(Role::ROLE_STAFF);
93
    }
94
}
95