74 lines
1.9 KiB
PHP
74 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Kwaadpepper\CrudPolicies\Enums\CrudAction;
|
|
use Kwaadpepper\CrudPolicies\Enums\CrudType;
|
|
use Kwaadpepper\CrudPolicies\Traits\IsCrudModel;
|
|
|
|
class Flash extends Model
|
|
{
|
|
use HasFactory;
|
|
use IsCrudModel;
|
|
|
|
protected $crudLabelColumn = 'title';
|
|
|
|
protected $crudValueColumn = 'id';
|
|
|
|
protected $fillable = [
|
|
'title',
|
|
'content',
|
|
'status'
|
|
];
|
|
|
|
public function __construct($attributes = [])
|
|
{
|
|
self::$editableProperties = [
|
|
'title' => [
|
|
'label' => trans('Titre'),
|
|
'type' => CrudType::string(),
|
|
'rule' => [
|
|
'max' => 255
|
|
],
|
|
'actions' => [
|
|
CrudAction::viewAny(),
|
|
CrudAction::view(),
|
|
CrudAction::create(),
|
|
CrudAction::update()
|
|
]
|
|
],
|
|
'content' => [
|
|
'label' => trans('Contenu'),
|
|
'type' => CrudType::text(),
|
|
'actions' => [
|
|
CrudAction::view(),
|
|
CrudAction::create(),
|
|
CrudAction::update()
|
|
]
|
|
],
|
|
'status' => [
|
|
'label' => trans('Publié'),
|
|
'type' => CrudType::boolean(),
|
|
'actions' => [
|
|
CrudAction::viewAny(),
|
|
CrudAction::view(),
|
|
CrudAction::create(),
|
|
CrudAction::update()
|
|
]
|
|
]
|
|
];
|
|
parent::__construct($attributes);
|
|
}
|
|
|
|
/**
|
|
* Has one Site
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function site()
|
|
{
|
|
return $this->belongsTo(Site::class);
|
|
}
|
|
}
|