1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Models; |
4
|
|
|
|
5
|
|
|
use App\Notifications\ResetPasswordNotification; |
6
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable; |
7
|
|
|
use Illuminate\Notifications\Notifiable; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* App\Models\User. |
11
|
|
|
* |
12
|
|
|
* @property int $id |
13
|
|
|
* @property string $name |
14
|
|
|
* @property string $email |
15
|
|
|
* @property string $password |
16
|
|
|
* @property string|null $remember_token |
17
|
|
|
* @property bool $is_admin |
18
|
|
|
* @property \Illuminate\Support\Carbon $created_at |
19
|
|
|
* @property \Illuminate\Support\Carbon $updated_at |
20
|
|
|
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications |
21
|
|
|
* @property-read int|null $notifications_count |
22
|
|
|
* |
23
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|User newModelQuery() |
24
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|User newQuery() |
25
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|User query() |
26
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|User whereCreatedAt($value) |
27
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|User whereEmail($value) |
28
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|User whereId($value) |
29
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|User whereIsAdmin($value) |
30
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|User whereName($value) |
31
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|User wherePassword($value) |
32
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|User whereRememberToken($value) |
33
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|User whereUpdatedAt($value) |
34
|
|
|
* |
35
|
|
|
* @mixin \Eloquent |
36
|
|
|
*/ |
37
|
|
|
class User extends Authenticatable |
38
|
|
|
{ |
39
|
|
|
use Notifiable; |
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* The attributes that are mass assignable. |
43
|
|
|
* |
44
|
|
|
* @var array |
45
|
|
|
*/ |
46
|
|
|
protected $fillable = [ |
47
|
|
|
'name', 'email', 'password', 'is_admin', |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* The attributes that should be cast to native types. |
52
|
|
|
* |
53
|
|
|
* @var array |
54
|
|
|
*/ |
55
|
|
|
protected $casts = [ |
56
|
|
|
'is_admin' => 'boolean', |
57
|
|
|
]; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* The attributes that should be hidden for arrays. |
61
|
|
|
* |
62
|
|
|
* @var array |
63
|
|
|
*/ |
64
|
|
|
protected $hidden = [ |
65
|
|
|
'password', 'remember_token', |
66
|
|
|
]; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Send the password reset notification. |
70
|
|
|
* |
71
|
|
|
* @param string $token |
72
|
|
|
* |
73
|
|
|
* @return void |
74
|
|
|
*/ |
75
|
1 |
|
public function sendPasswordResetNotification($token) |
76
|
|
|
{ |
77
|
1 |
|
$this->notify(new ResetPasswordNotification($token)); |
78
|
1 |
|
} |
79
|
|
|
|
80
|
83 |
|
public function isAdmin() |
81
|
|
|
{ |
82
|
83 |
|
return $this->is_admin; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|