75 lines
1.6 KiB
PHP
75 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\Informations\InfoColorsEnum;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property string $title
|
|
* @property string $message
|
|
* @property InfoColorsEnum $type Defined by the InfoColorsEnum enum.
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
* @mixin \Eloquent
|
|
*/
|
|
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);
|
|
});
|
|
}
|
|
}
|