1 | <?php |
||
15 | class Link extends Model |
||
16 | { |
||
17 | use TouchesTimestamps; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $fillable = [ |
||
23 | 'original_url', |
||
24 | 'code', |
||
25 | 'requested_count', |
||
26 | 'used_count', |
||
27 | 'last_requested', |
||
28 | 'last_used', |
||
29 | ]; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $dates = [ |
||
35 | 'last_requested', |
||
36 | 'last_used', |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * Override or change name of the table from config file. |
||
41 | * @return \Illuminate\Config\Repository|mixed|string |
||
42 | */ |
||
43 | 30 | public function getTable() |
|
47 | |||
48 | /** |
||
49 | * Get the code from the ID of table. |
||
50 | * @return mixed|string |
||
51 | * @throws CodeGenerationException |
||
52 | */ |
||
53 | 19 | public function getCode() |
|
61 | |||
62 | /** |
||
63 | * Get resource by code. |
||
64 | * @param $code |
||
65 | * @return mixed |
||
66 | */ |
||
67 | 7 | public static function byCode($code) |
|
71 | |||
72 | /** |
||
73 | * Get full new shortened URL with code. |
||
74 | * @return string|null |
||
75 | */ |
||
76 | 11 | public function shortenedUrl() |
|
84 | } |
||
85 |