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