1 | <?php |
||
58 | class Page extends Model implements Sortable |
||
|
|||
59 | { |
||
60 | use HasSlug; |
||
61 | use Macroable; |
||
62 | use SoftDeletes; |
||
63 | use SortableTrait; |
||
64 | use HasTranslations; |
||
65 | use ValidatingTrait; |
||
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 = []) |
||
171 | |||
172 | /** |
||
173 | * Determine if a set mutator exists for an attribute. |
||
174 | * |
||
175 | * @param string $key |
||
176 | * |
||
177 | * @return bool |
||
178 | */ |
||
179 | public function hasSetMutator($key) |
||
185 | |||
186 | /** |
||
187 | * Determine if a get mutator exists for an attribute. |
||
188 | * |
||
189 | * @param string $key |
||
190 | * |
||
191 | * @return bool |
||
192 | */ |
||
193 | public function hasGetMutator($key) |
||
199 | |||
200 | /** |
||
201 | * Get all attached models of the given class to the page. |
||
202 | * |
||
203 | * @param string $class |
||
204 | * |
||
205 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
206 | */ |
||
207 | public function entries(string $class): MorphToMany |
||
211 | |||
212 | /** |
||
213 | * Get the options for generating the slug. |
||
214 | * |
||
215 | * @return \Spatie\Sluggable\SlugOptions |
||
216 | */ |
||
217 | public function getSlugOptions(): SlugOptions |
||
224 | |||
225 | /** |
||
226 | * Activate the page. |
||
227 | * |
||
228 | * @return $this |
||
229 | */ |
||
230 | public function activate() |
||
236 | |||
237 | /** |
||
238 | * Deactivate the page. |
||
239 | * |
||
240 | * @return $this |
||
241 | */ |
||
242 | public function deactivate() |
||
248 | } |
||
249 |