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