ldc-boutique-cnc-sable/app/Models/Setting.php

47 lines
919 B
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
namespace App\Models;
use App\Casts\EmployeeSitesCast;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string[]|null $employee_sites
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
*
* @mixin \Eloquent
*/
class Setting extends Model
{
public const int SINGLETON_ID = 1;
protected $fillable = [
'employee_sites',
];
/**
* @return array<string, class-string|string>
*/
#[\Override]
protected function casts(): array
{
return [
'employee_sites' => EmployeeSitesCast::class,
];
}
public static function getSingleton(): self
{
return self::query()->firstOrCreate(
['id' => self::SINGLETON_ID],
[
'employee_sites' => [],
]
);
}
}