FEATURE #1523: add subpages for content
This commit is contained in:
+29
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user