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, |
|
|
|
|
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
|
|
|
|