FEATURE: add enumeration for content statuses

This commit is contained in:
Michal Kváček
2016-01-27 16:02:45 +01:00
parent 686ce63ca7
commit 4506b62387
3 changed files with 32 additions and 5 deletions
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Enumerations;
use App\Models\Content;
class ContentStatuses extends BaseEnumeration
{
protected static function init()
{
$roles = [
Content::STATUS_DRAFT => 'admin/contents.status_' . Content::STATUS_DRAFT,
Content::STATUS_DELETED => 'admin/contents.status_' . Content::STATUS_DELETED,
Content::STATUS_PROTECTED => 'admin/contents.status_' . Content::STATUS_PROTECTED,
Content::STATUS_PUBLIC => 'admin/contents.status_' . Content::STATUS_PUBLIC
];
foreach ($roles as $role => $translation) {
self::push($role, $translation);
}
}
}
+4 -5
View File
@@ -9,9 +9,7 @@ use Illuminate\Database\Eloquent\Model;
*/ */
class Content extends Model class Content extends Model
{ {
public $timestamps = true; public $timestamps = true;
protected $fillable = [ protected $fillable = [
'user_id', 'user_id',
'module_handler', 'module_handler',
@@ -26,8 +24,9 @@ class Content extends Model
'published_to', 'published_to',
'status' 'status'
]; ];
protected $guarded = []; protected $guarded = [];
const STATUS_DELETED = 'deleted';
const STATUS_DRAFT = 'draft';
const STATUS_PROTECTED = 'protected';
const STATUS_PUBLIC = 'public';
} }
+7
View File
@@ -0,0 +1,7 @@
<?php
return [
'status_deleted' => 'Deleted',
'status_draft' => 'Draft',
'status_protected' => 'Protected',
'status_public' => 'Public'
];