REFACTORING: move part of content business logic into repository
This commit is contained in:
@@ -36,49 +36,6 @@ class Content extends Model
|
||||
'module_settings',
|
||||
'status'
|
||||
];
|
||||
const STATUS_DRAFT = 'draft';
|
||||
const STATUS_PROTECTED = 'protected';
|
||||
const STATUS_PUBLIC = 'public';
|
||||
|
||||
/**
|
||||
* Is current content draft?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDraft()
|
||||
{
|
||||
return $this->status == self::STATUS_DRAFT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is current content visible for all visitors?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPublic()
|
||||
{
|
||||
return $this->status == self::STATUS_PUBLIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is current content visible only for logged users?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isProtected()
|
||||
{
|
||||
return $this->status == self::STATUS_PROTECTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is current content visible for logged user OR for everyone?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isVisible()
|
||||
{
|
||||
return $this->isPublic() || $this->isProtected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark relationship with its historical records
|
||||
@@ -119,16 +76,4 @@ class Content extends Model
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
public function save(array $options = [])
|
||||
{
|
||||
$saved = parent::save($options);
|
||||
|
||||
// fire event about creating new content page
|
||||
if ($this->wasRecentlyCreated) {
|
||||
Event::fire(new CreateNewContent($this));
|
||||
}
|
||||
|
||||
return $saved;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user