1
|
|
|
<?php namespace Arcanesoft\Seo\Models; |
2
|
|
|
|
3
|
|
|
use Arcanedev\LaravelSeo\Traits\Seoable; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class Footer |
7
|
|
|
* |
8
|
|
|
* @package Arcanesoft\Seo\Models |
9
|
|
|
* @author ARCANEDEV <[email protected]> |
10
|
|
|
* |
11
|
|
|
* @property int id |
12
|
|
|
* @property int page_id |
13
|
|
|
* @property string locale |
14
|
|
|
* @property string uri |
15
|
|
|
* @property string name |
16
|
|
|
* @property string localization |
17
|
|
|
* @property \Carbon\Carbon created_at |
18
|
|
|
* @property \Carbon\Carbon updated_at |
19
|
|
|
* |
20
|
|
|
* @property \Arcanesoft\Seo\Models\Page page |
21
|
|
|
*/ |
22
|
|
|
class Footer extends AbstractModel |
23
|
|
|
{ |
24
|
|
|
/* ----------------------------------------------------------------- |
25
|
|
|
| Traits |
26
|
|
|
| ----------------------------------------------------------------- |
27
|
|
|
*/ |
28
|
|
|
use Seoable, |
29
|
|
|
Presenters\FooterPresenter; |
30
|
|
|
|
31
|
|
|
/* ----------------------------------------------------------------- |
32
|
|
|
| Properties |
33
|
|
|
| ----------------------------------------------------------------- |
34
|
|
|
*/ |
35
|
|
|
/** |
36
|
|
|
* The attributes that are mass assignable. |
37
|
|
|
* |
38
|
|
|
* @var array |
39
|
|
|
*/ |
40
|
|
|
protected $fillable = [ |
41
|
|
|
'page_id', 'locale', 'uri', 'name', 'localization', |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* The attributes that should be cast to native types. |
46
|
|
|
* |
47
|
|
|
* @var array |
48
|
|
|
*/ |
49
|
|
|
protected $casts = [ |
50
|
|
|
'id' => 'integer', |
51
|
|
|
'page_id' => 'integer', |
52
|
|
|
]; |
53
|
|
|
|
54
|
|
|
/* ----------------------------------------------------------------- |
55
|
|
|
| Constructor |
56
|
|
|
| ----------------------------------------------------------------- |
57
|
|
|
*/ |
58
|
|
|
/** |
59
|
|
|
* Footer constructor. |
60
|
|
|
* |
61
|
|
|
* @param array $attributes |
62
|
|
|
*/ |
63
|
|
|
public function __construct(array $attributes = []) |
64
|
|
|
{ |
65
|
|
|
parent::__construct($attributes); |
66
|
|
|
|
67
|
|
|
$this->setConnection(config('arcanesoft.seo.database.connection')); |
68
|
|
|
$this->setPrefix(config('arcanesoft.seo.database.prefix', 'seo_')); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* The "booting" method of the model. |
73
|
|
|
* |
74
|
|
|
* @todo: Refactor to dedicated observer |
75
|
|
|
*/ |
76
|
|
|
protected static function boot() |
77
|
|
|
{ |
78
|
|
|
parent::boot(); |
79
|
|
|
|
80
|
|
|
self::deleting(function (Footer $footer) { |
81
|
|
|
$footer->deleteSeo(); |
82
|
|
|
}); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/* ----------------------------------------------------------------- |
86
|
|
|
| Relationships |
87
|
|
|
| ----------------------------------------------------------------- |
88
|
|
|
*/ |
89
|
|
|
/** |
90
|
|
|
* Page's relationship. |
91
|
|
|
* |
92
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
93
|
|
|
*/ |
94
|
|
|
public function page() |
95
|
|
|
{ |
96
|
|
|
return $this->belongsTo(Page::class); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/* ----------------------------------------------------------------- |
100
|
|
|
| Main Methods |
101
|
|
|
| ----------------------------------------------------------------- |
102
|
|
|
*/ |
103
|
|
|
public static function createOne(array $attributes) |
104
|
|
|
{ |
105
|
|
|
$footer = new self([ |
106
|
|
|
'name' => $attributes['name'], |
107
|
|
|
'localization' => $attributes['localization'], |
108
|
|
|
'uri' => $attributes['uri'], |
109
|
|
|
'locale' => $attributes['locale'], |
110
|
|
|
'page_id' => $attributes['page'], |
111
|
|
|
]); |
112
|
|
|
|
113
|
|
|
$footer->save(); |
114
|
|
|
|
115
|
|
|
$footer->createSeo([ |
116
|
|
|
'title' => $attributes['seo_title'], |
117
|
|
|
'description' => $attributes['seo_description'], |
118
|
|
|
'keywords' => $attributes['seo_keywords'], |
119
|
|
|
]); |
120
|
|
|
|
121
|
|
|
return $footer; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function updateOne(array $attributes) |
125
|
|
|
{ |
126
|
|
|
$result = $this->update([ |
127
|
|
|
'name' => $attributes['name'], |
128
|
|
|
'localization' => $attributes['localization'], |
129
|
|
|
'uri' => $attributes['uri'], |
130
|
|
|
'locale' => $attributes['locale'], |
131
|
|
|
'page_id' => $attributes['page'], |
132
|
|
|
]); |
133
|
|
|
|
134
|
|
|
$this->updateSeo([ |
135
|
|
|
'title' => $attributes['seo_title'], |
136
|
|
|
'description' => $attributes['seo_description'], |
137
|
|
|
'keywords' => $attributes['seo_keywords'], |
138
|
|
|
]); |
139
|
|
|
|
140
|
|
|
return $result; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/* ----------------------------------------------------------------- |
144
|
|
|
| Other Methods |
145
|
|
|
| ----------------------------------------------------------------- |
146
|
|
|
*/ |
147
|
|
|
public function getShowUrl() |
148
|
|
|
{ |
149
|
|
|
return route('admin::seo.footers.show', $this); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function getEditUrl() |
153
|
|
|
{ |
154
|
|
|
return route('admin::seo.footers.edit', $this); |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|