-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.php
102 lines (90 loc) · 2.45 KB
/
User.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Support\Facades\Hash;
class User extends Authenticatable
{
use HasApiTokens;
use HasFactory;
use Notifiable;
use SoftDeletes;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* the format date be used when actually storing a model's dates.
*
* @var string
*/
protected $dateFormat = 'Y-m-d H:i:s';
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
// protected $fillable = [];
/**
* The attributes that aren't mass assignable.
*
* @var array<int, string>
*/
protected $guarded = [];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* @var array<int, string>
*/
protected $dates = [
'email_verified_at',
'created_at',
'updated_at',
'deleted_at',
'activated_at',
'deactivated_at',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime:Y-m-d H:i:s',
'created_at' => 'datetime:Y-m-d H:i:s',
'updated_at' => 'datetime:Y-m-d H:i:s',
'deleted_at' => 'datetime:Y-m-d H:i:s',
'is_active' => 'boolean',
'activated_at' => 'datetime:Y-m-d H:i:s',
'deactivated_at' => 'datetime:Y-m-d H:i:s',
];
public function getRouteKeyName()
{
return 'uuid';
}
/**
* @param $password
*/
public function setPasswordAttribute($password): void
{
// If password was accidentally passed in already hashed, try not to double hash it
// Note: Password Histories are logged from the \App\Domains\Auth\Observer\UserObserver class
$this->attributes['password'] =
(strlen($password) === 60 && preg_match('/^\$2y\$/', $password)) ||
(strlen($password) === 95 && preg_match('/^\$argon2i\$/', $password)) ?
$password :
Hash::make($password);
}
}