null, "slug" => null, "role" => null, "icon" => null, "parent_id" => null ]; protected $casts = [ "name" => "string", "slug" => "string", "role" => "string", "icon" => "string", "parent_id" => "int" ]; public function withPage(): self { $this->attributes['pages'] = $this->page(); return $this; } public function withContents(string $locale = "es"): self { $m = model(WikiContentModel::class); $this->attributes['contents'] = $this->content($locale); return $this; } public function withAll(string $locale = "es") : self { $this->withPage(); $this->withContents($locale); return $this; } public function page(): ?WikiPageEntity { $m = model(WikiPageModel::class); return $m->where('section_id',$this->attributes['id'])->first(); } public function content(string $locale = "es"): ?WikiContentEntity { $page = $this->page(); $content = null; $m = model(WikiContentModel::class); if($page){ $content = $m->where('page_id',$page->id) ->where('locale',$locale) ->first(); } return $content; } }