'integer', 'public' => 'boolean', 'enabled' => 'boolean', 'new_window' => 'boolean', ]; public static $rules = [ 'name' => 'required|unique:pages,name', 'body' => 'nullable', 'type' => 'required', ]; /** * Return the full URL to this page; determines if it's internal or external * * @throws \App\Exceptions\UnknownPageType */ public function getUrlAttribute(): string { if ($this->type === PageType::PAGE) { return url(route('frontend.pages.show', ['slug' => $this->slug])); } if ($this->type === PageType::LINK) { return $this->link; } throw new UnknownPageType($this); } }