1 | <?php |
||
18 | class Page extends Model implements Sortable |
||
19 | { |
||
20 | use HasSlug; |
||
21 | use SortableTrait; |
||
22 | use HasTranslations; |
||
23 | use CacheableEloquent; |
||
24 | use ValidatingTrait, UniqueInjector |
||
25 | { |
||
26 | UniqueInjector::prepareUniqueRule insteadof ValidatingTrait; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | protected $fillable = [ |
||
33 | 'uri', |
||
34 | 'slug', |
||
35 | 'title', |
||
36 | 'subtitle', |
||
37 | 'domain', |
||
38 | 'middleware', |
||
39 | 'excerpt', |
||
40 | 'content', |
||
41 | 'view', |
||
42 | 'is_active', |
||
43 | 'sort_order', |
||
44 | ]; |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | protected $casts = [ |
||
50 | 'uri' => 'string', |
||
51 | 'slug' => 'string', |
||
52 | 'title' => 'string', |
||
53 | 'subtitle' => 'string', |
||
54 | 'domain' => 'string', |
||
55 | 'middleware' => 'string', |
||
56 | 'excerpt' => 'string', |
||
57 | 'content' => 'string', |
||
58 | 'view' => 'string', |
||
59 | 'is_active' => 'boolean', |
||
60 | 'sort_order' => 'integer', |
||
61 | 'deleted_at' => 'datetime', |
||
62 | ]; |
||
63 | |||
64 | /** |
||
65 | * {@inheritdoc} |
||
66 | */ |
||
67 | protected $observables = [ |
||
68 | 'validating', |
||
69 | 'validated', |
||
70 | ]; |
||
71 | |||
72 | /** |
||
73 | * {@inheritdoc} |
||
74 | */ |
||
75 | public $translatable = [ |
||
76 | 'title', |
||
77 | 'subtitle', |
||
78 | 'excerpt', |
||
79 | 'content', |
||
80 | ]; |
||
81 | |||
82 | /** |
||
83 | * {@inheritdoc} |
||
84 | */ |
||
85 | public $sortable = [ |
||
86 | 'order_column_name' => 'sort_order', |
||
87 | ]; |
||
88 | |||
89 | /** |
||
90 | * The default rules that the model will validate against. |
||
91 | * |
||
92 | * @var array |
||
93 | */ |
||
94 | protected $rules = []; |
||
95 | |||
96 | /** |
||
97 | * Whether the model should throw a |
||
98 | * ValidationException if it fails validation. |
||
99 | * |
||
100 | * @var bool |
||
101 | */ |
||
102 | protected $throwValidationExceptions = true; |
||
103 | |||
104 | /** |
||
105 | * Create a new Eloquent model instance. |
||
106 | * |
||
107 | * @param array $attributes |
||
108 | */ |
||
109 | public function __construct(array $attributes = []) |
||
128 | |||
129 | /** |
||
130 | * {@inheritdoc} |
||
131 | */ |
||
132 | protected static function boot() |
||
147 | |||
148 | /** |
||
149 | * Get the active pages. |
||
150 | * |
||
151 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
152 | * |
||
153 | * @return \Illuminate\Database\Eloquent\Builder |
||
154 | */ |
||
155 | public function scopeActive(Builder $builder): Builder |
||
159 | |||
160 | /** |
||
161 | * Get the inactive pages. |
||
162 | * |
||
163 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
164 | * |
||
165 | * @return \Illuminate\Database\Eloquent\Builder |
||
166 | */ |
||
167 | public function scopeInactive(Builder $builder): Builder |
||
171 | |||
172 | /** |
||
173 | * Set the translatable title attribute. |
||
174 | * |
||
175 | * @param string $value |
||
176 | * |
||
177 | * @return void |
||
178 | */ |
||
179 | public function setTitleAttribute($value) |
||
183 | |||
184 | /** |
||
185 | * Set the translatable subtitle attribute. |
||
186 | * |
||
187 | * @param string $value |
||
188 | * |
||
189 | * @return void |
||
190 | */ |
||
191 | public function setSubtitleAttribute($value) |
||
195 | |||
196 | /** |
||
197 | * Set the translatable excerpt attribute. |
||
198 | * |
||
199 | * @param string $value |
||
200 | * |
||
201 | * @return void |
||
202 | */ |
||
203 | public function setExcerptAttribute($value) |
||
207 | |||
208 | /** |
||
209 | * Set the translatable content attribute. |
||
210 | * |
||
211 | * @param string $value |
||
212 | * |
||
213 | * @return void |
||
214 | */ |
||
215 | public function setContentAttribute($value) |
||
219 | |||
220 | /** |
||
221 | * Get the options for generating the slug. |
||
222 | * |
||
223 | * @return \Spatie\Sluggable\SlugOptions |
||
224 | */ |
||
225 | public function getSlugOptions(): SlugOptions |
||
232 | |||
233 | /** |
||
234 | * Active the page. |
||
235 | * |
||
236 | * @return $this |
||
237 | */ |
||
238 | public function activate(): self |
||
244 | |||
245 | /** |
||
246 | * Deactivate the page. |
||
247 | * |
||
248 | * @return $this |
||
249 | */ |
||
250 | public function deactivate(): self |
||
256 | } |
||
257 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.