|
1
|
|
|
<?php namespace Arcanedev\LaravelSeo\Models; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanedev\LaravelSeo\Seo; |
|
4
|
|
|
use Illuminate\Support\Arr; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class Meta |
|
8
|
|
|
* |
|
9
|
|
|
* @package Arcanedev\LaravelSeo\Models |
|
10
|
|
|
* @author ARCANEDEV <[email protected]> |
|
11
|
|
|
* |
|
12
|
|
|
* @property int id |
|
13
|
|
|
* @property int seoable_id |
|
14
|
|
|
* @property string seoable_type |
|
15
|
|
|
* @property string title |
|
16
|
|
|
* @property string description |
|
17
|
|
|
* @property \Illuminate\Support\Collection keywords |
|
18
|
|
|
* @property \Illuminate\Support\Collection metas |
|
19
|
|
|
* @property boolean noindex |
|
20
|
|
|
* @property \Carbon\Carbon created_at |
|
21
|
|
|
* @property \Carbon\Carbon updated_at |
|
22
|
|
|
* |
|
23
|
|
|
* @property \Illuminate\Database\Eloquent\Model seoable |
|
24
|
|
|
*/ |
|
25
|
|
|
class Meta extends AbstractModel |
|
26
|
|
|
{ |
|
27
|
|
|
/* ----------------------------------------------------------------- |
|
28
|
|
|
| Properties |
|
29
|
|
|
| ----------------------------------------------------------------- |
|
30
|
|
|
*/ |
|
31
|
|
|
/** |
|
32
|
|
|
* The attributes that are mass assignable. |
|
33
|
|
|
* |
|
34
|
|
|
* @var array |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $fillable = ['title', 'description', 'keywords', 'metas', 'noindex']; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* The attributes that should be casted to native types. |
|
40
|
|
|
* |
|
41
|
|
|
* @var array |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $casts = [ |
|
44
|
|
|
'id' => 'integer', |
|
45
|
|
|
'seoable_id' => 'integer', |
|
46
|
|
|
'keywords' => 'collection', |
|
47
|
|
|
'metas' => 'collection', |
|
48
|
|
|
'noindex' => 'boolean', |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
/* ----------------------------------------------------------------- |
|
52
|
|
|
| Constructor |
|
53
|
|
|
| ----------------------------------------------------------------- |
|
54
|
|
|
*/ |
|
55
|
|
|
/** |
|
56
|
|
|
* Meta constructor. |
|
57
|
|
|
* |
|
58
|
|
|
* @param array $attributes |
|
59
|
|
|
*/ |
|
60
|
24 |
|
public function __construct(array $attributes = []) |
|
61
|
|
|
{ |
|
62
|
24 |
|
parent::__construct($attributes); |
|
63
|
|
|
|
|
64
|
24 |
|
$this->setTable(Seo::getConfig('metas.table', 'metas')); |
|
65
|
24 |
|
} |
|
66
|
|
|
|
|
67
|
|
|
/* ----------------------------------------------------------------- |
|
68
|
|
|
| Relationships |
|
69
|
|
|
| ----------------------------------------------------------------- |
|
70
|
|
|
*/ |
|
71
|
|
|
/** |
|
72
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\MorphTo |
|
73
|
|
|
*/ |
|
74
|
6 |
|
public function seoable() |
|
75
|
|
|
{ |
|
76
|
6 |
|
return $this->morphTo(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/* ----------------------------------------------------------------- |
|
80
|
|
|
| Other Methods |
|
81
|
|
|
| ----------------------------------------------------------------- |
|
82
|
|
|
*/ |
|
83
|
|
|
/** |
|
84
|
|
|
* Prepare the attributes. |
|
85
|
|
|
* |
|
86
|
|
|
* @param array $attributes |
|
87
|
|
|
* |
|
88
|
|
|
* @return array |
|
89
|
|
|
*/ |
|
90
|
24 |
|
public static function prepareAttributes(array $attributes) |
|
91
|
|
|
{ |
|
92
|
|
|
return [ |
|
93
|
24 |
|
'title' => Arr::get($attributes, 'title'), |
|
94
|
24 |
|
'description' => Arr::get($attributes, 'description'), |
|
95
|
24 |
|
'keywords' => Arr::get($attributes, 'keywords', []), |
|
96
|
24 |
|
'metas' => Arr::get($attributes, 'metas', []), |
|
97
|
24 |
|
'noindex' => Arr::get($attributes, 'noindex', false), |
|
98
|
8 |
|
]; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|