REFACTORING: move part of content business logic into repository

This commit is contained in:
Michal Kváček
2016-10-18 15:36:26 +02:00
parent eabbf48ee0
commit 662700b4f2
19 changed files with 504 additions and 383 deletions
-55
View File
@@ -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;
}
}