1 | <?php namespace Arcanedev\LaravelSeo\Models; |
||
21 | class Redirect extends AbstractModel |
||
22 | { |
||
23 | /* ----------------------------------------------------------------- |
||
24 | | Properties |
||
25 | | ----------------------------------------------------------------- |
||
26 | */ |
||
27 | |||
28 | /** |
||
29 | * The attributes that are mass assignable. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $fillable = ['old_url', 'new_url', 'status']; |
||
34 | |||
35 | /** |
||
36 | * The attributes that should be cast to native types. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $casts = [ |
||
41 | 'status' => 'integer', |
||
42 | ]; |
||
43 | |||
44 | /* ----------------------------------------------------------------- |
||
45 | | Constructor |
||
46 | | ----------------------------------------------------------------- |
||
47 | */ |
||
48 | |||
49 | /** |
||
50 | * Meta constructor. |
||
51 | * |
||
52 | * @param array $attributes |
||
53 | */ |
||
54 | 4 | public function __construct(array $attributes = []) |
|
60 | |||
61 | /** |
||
62 | * The "booting" method of the model. |
||
63 | */ |
||
64 | 4 | public static function boot() |
|
77 | |||
78 | /* ----------------------------------------------------------------- |
||
79 | | Getters & Setters |
||
80 | | ----------------------------------------------------------------- |
||
81 | */ |
||
82 | |||
83 | /** |
||
84 | * Get the `status_name` attribute. |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | 2 | public function getStatusNameAttribute() |
|
92 | |||
93 | /* ----------------------------------------------------------------- |
||
94 | | Main Methods |
||
95 | | ----------------------------------------------------------------- |
||
96 | */ |
||
97 | |||
98 | /** |
||
99 | * Create a redirect url. |
||
100 | * |
||
101 | * @param string $oldUrl |
||
102 | * @param string $newUrl |
||
103 | * @param int $status |
||
104 | * |
||
105 | * @return \Arcanedev\LaravelSeo\Models\Redirect |
||
106 | */ |
||
107 | 4 | public static function createOne($oldUrl, $newUrl, $status = Response::HTTP_MOVED_PERMANENTLY) |
|
119 | |||
120 | /* ----------------------------------------------------------------- |
||
121 | | Other Methods |
||
122 | | ----------------------------------------------------------------- |
||
123 | */ |
||
124 | |||
125 | /** |
||
126 | * Clear the cached data. |
||
127 | */ |
||
128 | 4 | protected static function clearCache() |
|
134 | } |
||
135 |