ldc-supportweb/app/Models/Information.php

72 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace App\Models;
use App\Enums\Informations\InfoColorsEnum;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property string $title
* @property string $message
* @property InfoColorsEnum $type
*/
class Information extends Model
{
use HasFactory;
/**
* Indicates if the model should be timestamped.
*
* @var boolean
*/
public $timestamps = true;
/**
* The table associated with this model
*
* @var string
*/
protected $table = 'informations';
/**
* The attributes that are fillable.
*
* @var array
*/
protected $fillable = [
'title',
'message',
'type'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'type' => InfoColorsEnum::class,
];
// * EVENTS
/**
* Perform any actions required after the model boots.
*
* @return void
*/
protected static function booted()
{
static::created(function () {
cache()->put('infos', Information::all(), 3600);
});
static::updated(function () {
cache()->put('infos', Information::all(), 3600);
});
static::deleted(function () {
cache()->put('infos', Information::all(), 3600);
});
}
}