2023-04-18 13:57:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2023-08-14 09:23:39 +00:00
|
|
|
use App\Enums\Informations\InfoColorsEnum;
|
2023-04-18 13:57:34 +00:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
2023-08-14 09:23:39 +00:00
|
|
|
/**
|
|
|
|
|
* @property string $title
|
|
|
|
|
* @property string $message
|
|
|
|
|
* @property InfoColorsEnum $type
|
|
|
|
|
*/
|
2023-04-18 13:57:34 +00:00
|
|
|
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';
|
|
|
|
|
|
|
|
|
|
/**
|
2023-08-14 09:23:39 +00:00
|
|
|
* The attributes that are fillable.
|
2023-04-18 13:57:34 +00:00
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'title',
|
|
|
|
|
'message',
|
|
|
|
|
'type'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
2023-08-14 09:23:39 +00:00
|
|
|
* The attributes that should be cast.
|
2023-04-18 13:57:34 +00:00
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
2023-08-14 09:23:39 +00:00
|
|
|
protected $casts = [
|
|
|
|
|
'type' => InfoColorsEnum::class,
|
2023-04-18 13:57:34 +00:00
|
|
|
];
|
|
|
|
|
|
2023-08-14 09:23:39 +00:00
|
|
|
// * EVENTS
|
|
|
|
|
|
2023-04-18 13:57:34 +00:00
|
|
|
/**
|
2023-08-14 09:23:39 +00:00
|
|
|
* Perform any actions required after the model boots.
|
2023-04-18 13:57:34 +00:00
|
|
|
*
|
2023-08-14 09:23:39 +00:00
|
|
|
* @return void
|
2023-04-18 13:57:34 +00:00
|
|
|
*/
|
2023-08-14 09:23:39 +00:00
|
|
|
protected static function booted()
|
2023-04-18 13:57:34 +00:00
|
|
|
{
|
2023-08-14 09:23:39 +00:00
|
|
|
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);
|
|
|
|
|
});
|
2023-04-18 13:57:34 +00:00
|
|
|
}
|
|
|
|
|
}
|