1 | <?php |
||
59 | class Page extends Model implements PageContract, Sortable |
||
60 | { |
||
61 | use HasSlug; |
||
62 | use SortableTrait; |
||
63 | use HasTranslations; |
||
64 | use ValidatingTrait; |
||
65 | use CacheableEloquent; |
||
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | protected $fillable = [ |
||
71 | 'uri', |
||
72 | 'slug', |
||
73 | 'title', |
||
74 | 'route', |
||
75 | 'subtitle', |
||
76 | 'domain', |
||
77 | 'middleware', |
||
78 | 'excerpt', |
||
79 | 'content', |
||
80 | 'view', |
||
81 | 'is_active', |
||
82 | 'sort_order', |
||
83 | ]; |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | protected $casts = [ |
||
89 | 'uri' => 'string', |
||
90 | 'slug' => 'string', |
||
91 | 'route' => 'string', |
||
92 | 'domain' => 'string', |
||
93 | 'middleware' => 'string', |
||
94 | 'view' => 'string', |
||
95 | 'is_active' => 'boolean', |
||
96 | 'sort_order' => 'integer', |
||
97 | 'deleted_at' => 'datetime', |
||
98 | ]; |
||
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | protected $observables = [ |
||
104 | 'validating', |
||
105 | 'validated', |
||
106 | ]; |
||
107 | |||
108 | /** |
||
109 | * {@inheritdoc} |
||
110 | */ |
||
111 | public $translatable = [ |
||
112 | 'title', |
||
113 | 'subtitle', |
||
114 | 'excerpt', |
||
115 | 'content', |
||
116 | ]; |
||
117 | |||
118 | /** |
||
119 | * {@inheritdoc} |
||
120 | */ |
||
121 | public $sortable = [ |
||
122 | 'order_column_name' => 'sort_order', |
||
123 | ]; |
||
124 | |||
125 | /** |
||
126 | * The default rules that the model will validate against. |
||
127 | * |
||
128 | * @var array |
||
129 | */ |
||
130 | protected $rules = []; |
||
131 | |||
132 | /** |
||
133 | * Whether the model should throw a |
||
134 | * ValidationException if it fails validation. |
||
135 | * |
||
136 | * @var bool |
||
137 | */ |
||
138 | protected $throwValidationExceptions = true; |
||
139 | |||
140 | /** |
||
141 | * Create a new Eloquent model instance. |
||
142 | * |
||
143 | * @param array $attributes |
||
144 | */ |
||
145 | public function __construct(array $attributes = []) |
||
165 | |||
166 | /** |
||
167 | * Get the active pages. |
||
168 | * |
||
169 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
170 | * |
||
171 | * @return \Illuminate\Database\Eloquent\Builder |
||
172 | */ |
||
173 | public function scopeActive(Builder $builder): Builder |
||
177 | |||
178 | /** |
||
179 | * Get the inactive pages. |
||
180 | * |
||
181 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
182 | * |
||
183 | * @return \Illuminate\Database\Eloquent\Builder |
||
184 | */ |
||
185 | public function scopeInactive(Builder $builder): Builder |
||
189 | |||
190 | /** |
||
191 | * Get the options for generating the slug. |
||
192 | * |
||
193 | * @return \Spatie\Sluggable\SlugOptions |
||
194 | */ |
||
195 | public function getSlugOptions(): SlugOptions |
||
202 | |||
203 | /** |
||
204 | * Activate the page. |
||
205 | * |
||
206 | * @return $this |
||
207 | */ |
||
208 | public function activate() |
||
214 | |||
215 | /** |
||
216 | * Deactivate the page. |
||
217 | * |
||
218 | * @return $this |
||
219 | */ |
||
220 | public function deactivate() |
||
226 | } |
||
227 |
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.