1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Models; |
4
|
|
|
|
5
|
|
|
use App\Enum\Gender; |
6
|
|
|
use App\Infrastructure\Foundation\Auth\User as Authenticatable; |
7
|
|
|
use App\Models\Contracts\HasTelegramChatId; |
8
|
|
|
use App\Models\Contracts\Issuerable; |
9
|
|
|
use App\Notifications\ResetPasswordQueued; |
10
|
|
|
use App\Notifications\VerifyEmailQueued; |
11
|
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail; |
12
|
|
|
use Illuminate\Database\Eloquent\Collection; |
13
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory; |
14
|
|
|
use Illuminate\Notifications\Notifiable; |
15
|
|
|
use Propaganistas\LaravelPhone\Casts\E164PhoneNumberCast; |
16
|
|
|
|
17
|
|
|
class User extends Authenticatable implements MustVerifyEmail, Issuerable, HasTelegramChatId |
18
|
|
|
{ |
19
|
|
|
use HasFactory, Notifiable, |
|
|
|
|
20
|
|
|
Concerns\User\Attribute, |
21
|
|
|
Concerns\User\Event, |
22
|
|
|
Concerns\User\Relation; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritDoc} |
26
|
|
|
*/ |
27
|
|
|
protected $fillable = [ |
28
|
|
|
'telegram_chat_id', |
29
|
|
|
'username', |
30
|
|
|
'fullname', |
31
|
|
|
'gender', |
32
|
|
|
'email', |
33
|
|
|
'phone_country', |
34
|
|
|
'phone', |
35
|
|
|
'password', |
36
|
|
|
'is_active', |
37
|
|
|
]; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritDoc} |
41
|
|
|
*/ |
42
|
|
|
protected $hidden = [ |
43
|
|
|
'password', |
44
|
|
|
'remember_token', |
45
|
|
|
]; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* {@inheritDoc} |
49
|
|
|
*/ |
50
|
|
|
protected $casts = [ |
51
|
|
|
'gender' => Gender::class, |
52
|
|
|
'phone' => E164PhoneNumberCast::class, |
53
|
|
|
'email_verified_at' => 'datetime', |
54
|
|
|
'is_active' => 'boolean', |
55
|
|
|
]; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* {@inheritDoc} |
59
|
|
|
*/ |
60
|
|
|
public function getTelegramChatId(): string |
61
|
|
|
{ |
62
|
|
|
return $this->telegram_chat_id; |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* {@inheritDoc} |
67
|
|
|
*/ |
68
|
3 |
|
public function sendEmailVerificationNotification() |
69
|
|
|
{ |
70
|
3 |
|
$this->notify(new VerifyEmailQueued); |
71
|
3 |
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* {@inheritDoc} |
75
|
|
|
*/ |
76
|
3 |
|
public function sendPasswordResetNotification($token) |
77
|
|
|
{ |
78
|
3 |
|
$this->notify(new ResetPasswordQueued($token)); |
79
|
3 |
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* {@inheritDoc} |
83
|
|
|
*/ |
84
|
|
|
public function getIssuerFullname(): string |
85
|
|
|
{ |
86
|
|
|
return $this->fullname; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* {@inheritDoc} |
91
|
|
|
*/ |
92
|
|
|
public function getIssuerRole(): string |
93
|
|
|
{ |
94
|
|
|
return trans('admin-lang.user'); |
|
|
|
|
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* {@inheritDoc} |
99
|
|
|
*/ |
100
|
|
|
public function getIssuerUrl(): string |
101
|
|
|
{ |
102
|
|
|
return route('admin.user.show', $this); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Return collection of model instance data where role is "admin". |
107
|
|
|
* |
108
|
|
|
* @param array|string $columns |
109
|
|
|
* @return \Illuminate\Database\Eloquent\Collection<static> |
110
|
|
|
*/ |
111
|
|
|
public static function getAdmin($columns = ['*']): Collection |
112
|
|
|
{ |
113
|
|
|
return static::role(Role::ROLE_ADMIN)->get($columns); |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|