FEATURE: add new relationship to Content model - only visible subpages
This commit is contained in:
@@ -103,6 +103,23 @@ class Content extends Model
|
|||||||
return $this->hasMany(Content::class, 'parentId');
|
return $this->hasMany(Content::class, 'parentId');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subpages assigned to page
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
|
*/
|
||||||
|
public function publishedSubpages()
|
||||||
|
{
|
||||||
|
$query = $this->hasMany(Content::class, 'parentId');
|
||||||
|
|
||||||
|
if (\Auth::check()) {
|
||||||
|
$query = $query->where('status', '!=', ContentContract::STATUS_DRAFT);
|
||||||
|
} else {
|
||||||
|
$query = $query->where('status', ContentContract::STATUS_PUBLIC);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module relationship
|
* Module relationship
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
|
|||||||
Reference in New Issue
Block a user