2022-10-03 17:13:44 +02:00
|
|
|
<?php
|
|
|
|
|
|
2023-03-01 11:02:42 +01:00
|
|
|
namespace App\Models\Site;
|
2022-10-03 17:13:44 +02:00
|
|
|
|
|
|
|
|
use App\Enums\GeneralConfigType;
|
2023-03-17 17:32:18 +01:00
|
|
|
use App\Traits\Models\IsCachedAsCollection;
|
2022-10-03 17:13:44 +02:00
|
|
|
use App\Traits\Models\MiniCrudModel;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Kwaadpepper\Enum\Traits\CastsEnums;
|
|
|
|
|
|
2023-03-22 17:17:46 +01:00
|
|
|
/**
|
|
|
|
|
* GeneralConfig
|
|
|
|
|
*
|
|
|
|
|
* @property \App\Enums\GeneralConfigType $type The general type.
|
|
|
|
|
* @property object $data The general config data array.
|
|
|
|
|
*
|
|
|
|
|
* @package App\Models
|
|
|
|
|
*
|
|
|
|
|
*/
|
2022-10-03 17:13:44 +02:00
|
|
|
class GeneralConfig extends Model
|
|
|
|
|
{
|
|
|
|
|
use CastsEnums;
|
|
|
|
|
use MiniCrudModel;
|
2023-03-17 17:32:18 +01:00
|
|
|
use IsCachedAsCollection;
|
2022-10-03 17:13:44 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The primary key for the model.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $primaryKey = 'type';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates if the IDs are auto-incrementing.
|
|
|
|
|
*
|
|
|
|
|
* @var boolean
|
|
|
|
|
*/
|
|
|
|
|
public $incrementing = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that should be cast.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
protected $casts = [
|
2022-12-19 16:20:00 +01:00
|
|
|
'data' => 'object'
|
2022-10-03 17:13:44 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that should be cast to Enums.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
protected $enumCasts = [
|
|
|
|
|
'type' => GeneralConfigType::class
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'type', 'data'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Perform any actions required after the model boots.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected static function booted()
|
|
|
|
|
{
|
2023-03-24 15:06:31 +01:00
|
|
|
static::created(function () {
|
|
|
|
|
self::removeCached();
|
2022-10-03 17:13:44 +02:00
|
|
|
});
|
2023-03-24 15:06:31 +01:00
|
|
|
static::updated(function () {
|
|
|
|
|
self::removeCached();
|
2022-10-03 17:13:44 +02:00
|
|
|
});
|
2023-03-24 15:06:31 +01:00
|
|
|
static::deleted(function () {
|
|
|
|
|
self::removeCached();
|
2022-10-03 17:13:44 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|