1 | <?php |
||
57 | class Page extends Model implements Sortable |
||
58 | { |
||
59 | use HasSlug; |
||
60 | use Macroable; |
||
61 | use SortableTrait; |
||
62 | use HasTranslations; |
||
63 | use ValidatingTrait; |
||
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | protected $fillable = [ |
||
69 | 'uri', |
||
70 | 'slug', |
||
71 | 'title', |
||
72 | 'route', |
||
73 | 'subtitle', |
||
74 | 'domain', |
||
75 | 'middleware', |
||
76 | 'excerpt', |
||
77 | 'content', |
||
78 | 'view', |
||
79 | 'is_active', |
||
80 | 'sort_order', |
||
81 | ]; |
||
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | protected $casts = [ |
||
87 | 'uri' => 'string', |
||
88 | 'slug' => 'string', |
||
89 | 'route' => 'string', |
||
90 | 'domain' => 'string', |
||
91 | 'middleware' => 'string', |
||
92 | 'view' => 'string', |
||
93 | 'is_active' => 'boolean', |
||
94 | 'sort_order' => 'integer', |
||
95 | 'deleted_at' => 'datetime', |
||
96 | ]; |
||
97 | |||
98 | /** |
||
99 | * {@inheritdoc} |
||
100 | */ |
||
101 | protected $observables = [ |
||
102 | 'validating', |
||
103 | 'validated', |
||
104 | ]; |
||
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | public $translatable = [ |
||
110 | 'title', |
||
111 | 'subtitle', |
||
112 | 'excerpt', |
||
113 | 'content', |
||
114 | ]; |
||
115 | |||
116 | /** |
||
117 | * {@inheritdoc} |
||
118 | */ |
||
119 | public $sortable = [ |
||
120 | 'order_column_name' => 'sort_order', |
||
121 | ]; |
||
122 | |||
123 | /** |
||
124 | * The default rules that the model will validate against. |
||
125 | * |
||
126 | * @var array |
||
127 | */ |
||
128 | protected $rules = []; |
||
129 | |||
130 | /** |
||
131 | * Whether the model should throw a |
||
132 | * ValidationException if it fails validation. |
||
133 | * |
||
134 | * @var bool |
||
135 | */ |
||
136 | protected $throwValidationExceptions = true; |
||
137 | |||
138 | /** |
||
139 | * Create a new Eloquent model instance. |
||
140 | * |
||
141 | * @param array $attributes |
||
142 | */ |
||
143 | public function __construct(array $attributes = []) |
||
169 | |||
170 | /** |
||
171 | * Determine if a set mutator exists for an attribute. |
||
172 | * |
||
173 | * @param string $key |
||
174 | * |
||
175 | * @return bool |
||
176 | */ |
||
177 | public function hasSetMutator($key) |
||
183 | |||
184 | /** |
||
185 | * Determine if a get mutator exists for an attribute. |
||
186 | * |
||
187 | * @param string $key |
||
188 | * |
||
189 | * @return bool |
||
190 | */ |
||
191 | public function hasGetMutator($key) |
||
197 | |||
198 | /** |
||
199 | * Get all attached models of the given class to the page. |
||
200 | * |
||
201 | * @param string $class |
||
202 | * |
||
203 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
204 | */ |
||
205 | public function entries(string $class): MorphToMany |
||
209 | |||
210 | /** |
||
211 | * Get the options for generating the slug. |
||
212 | * |
||
213 | * @return \Spatie\Sluggable\SlugOptions |
||
214 | */ |
||
215 | public function getSlugOptions(): SlugOptions |
||
222 | |||
223 | /** |
||
224 | * Activate the page. |
||
225 | * |
||
226 | * @return $this |
||
227 | */ |
||
228 | public function activate() |
||
234 | |||
235 | /** |
||
236 | * Deactivate the page. |
||
237 | * |
||
238 | * @return $this |
||
239 | */ |
||
240 | public function deactivate() |
||
246 | } |
||
247 |