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