FEATURE: cache results for Content::subpages()
This commit is contained in:
@@ -30,6 +30,8 @@ class Content extends Model
|
||||
'status'
|
||||
];
|
||||
protected $guarded = [];
|
||||
protected $subpages = [];
|
||||
protected $subpagesInit = false;
|
||||
const STATUS_DELETED = 'deleted';
|
||||
const STATUS_DRAFT = 'draft';
|
||||
const STATUS_PROTECTED = 'protected';
|
||||
@@ -76,9 +78,14 @@ class Content extends Model
|
||||
*/
|
||||
public function subpages()
|
||||
{
|
||||
return $this->getPageQuery()
|
||||
if (!$this->subpagesInit) {
|
||||
$this->subpages = $this->getPageQuery()
|
||||
->where('parent_id', $this->id)
|
||||
->get();
|
||||
$this->subpagesInit = true;
|
||||
}
|
||||
|
||||
return $this->subpages;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user