Total Complexity | 3 |
Total Lines | 66 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class AccessToken extends Model |
||
13 | { |
||
14 | use HasFactory; |
||
15 | |||
16 | protected $table = 'access_tokens'; |
||
17 | |||
18 | /** |
||
19 | * @var string[] |
||
20 | */ |
||
21 | protected $fillable = [ |
||
22 | 'token', |
||
23 | 'user_id', |
||
24 | 'user_type', |
||
25 | 'title', |
||
26 | 'expiration', |
||
27 | 'last_use', |
||
28 | ]; |
||
29 | |||
30 | /** |
||
31 | * @var string[] |
||
32 | */ |
||
33 | protected $dates = [ |
||
34 | 'expiration', |
||
35 | 'last_use', |
||
36 | 'created_at', |
||
37 | 'updated_at', |
||
38 | ]; |
||
39 | |||
40 | /** |
||
41 | * The attributes that should be casted to native types. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $casts = [ |
||
46 | 'id' => 'integer', |
||
47 | 'token' => 'string', |
||
48 | 'user_id' => 'integer', |
||
49 | 'user_type' => 'string', |
||
50 | 'title' => 'string', |
||
51 | 'last_use' => 'datetime', |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * Validation rules |
||
56 | * |
||
57 | * @var array |
||
58 | */ |
||
59 | public static array $rules = [ |
||
60 | 'token' => 'required', |
||
61 | ]; |
||
62 | |||
63 | /** |
||
64 | * @return MorphTo |
||
65 | */ |
||
66 | public function user(): MorphTo |
||
67 | { |
||
68 | return $this->morphTo(); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Проверка валидности токена по дате |
||
73 | * @return bool |
||
74 | */ |
||
75 | public function isValid(): bool |
||
78 | } |
||
79 | } |
||
80 |