FEATURE #1523: add subpages for content

This commit is contained in:
Michal Kváček
2016-03-31 21:12:54 +02:00
parent acc7541ab9
commit e789b02a93
10 changed files with 192 additions and 24 deletions
+29 -2
View File
@@ -43,7 +43,6 @@ class Content extends Model
/**
* Getter for homepage content page
*
* @return Content
*/
public function getHomepage()
@@ -68,8 +67,36 @@ class Content extends Model
}
/**
* Getter for overview of all content pages.
* Get list of all subpages
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function subpages()
{
return $this->getPageQuery()
->where('parent_id', $this->id)
->get();
}
/**
* Returns list of all root pages - those pages, which parent_id is null
*
* @return mixed
*/
public function rootPages()
{
$rootPages = $this->getPageQuery()
->where('parent_id', null);
if ($this->id) {
$rootPages = $rootPages->where('id', '!=', $this->id);
}
return $rootPages->get();
}
/**
* Getter for overview of all content pages.
* These content pages may be filtered by using some handler
*
* @param bool $handler