ldc-supportweb/app/Models/Information.php
2023-04-18 13:57:34 +00:00

120 lines
2.8 KiB
PHP

<?php
namespace App\Models;
use App\Enums\InfoColors;
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;
use Kwaadpepper\Enum\Traits\CastsEnums;
class Information extends Model
{
use CastsEnums;
use HasFactory;
use IsCrudModel;
/**
* Indicates if the model should be timestamped.
*
* @var boolean
*/
public $timestamps = true;
/**
* Crud label column
*
* @var string
*/
protected $crudLabelColumn = 'title';
/**
* The table associated with this model
*
* @var string
*/
protected $table = 'informations';
/**
* Crud value column
*
* @var string
*/
protected $crudValueColumn = 'id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'title',
'message',
'type'
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $enumCasts = [
'type' => InfoColors::class,
];
/**
* Package
*
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
self::$editableProperties = [
'title' => [
'label' => trans('Titre'),
'type' => CrudType::string(),
'validate' => [
'string',
'max:255'
],
'nullable' => false,
'actions' => [
CrudAction::viewAny(),
CrudAction::view(),
CrudAction::update(),
CrudAction::create()
]
],
'message' => [
'label' => trans('Message'),
'type' => CrudType::string(),
'validate' => [
'string',
'max:255'
],
'nullable' => false,
'actions' => [
CrudAction::viewAny(),
CrudAction::view(),
CrudAction::update(),
CrudAction::create()
]
],
'type' => [
'label' => trans('Type d\'annonce'),
'type' => CrudType::enum(),
'enum' => InfoColors::class,
'nullable' => false,
'actions' => [
CrudAction::viewAny(),
CrudAction::view(),
CrudAction::update(),
CrudAction::create()
]
],
];
parent::__construct($attributes);
}
}