Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
AppSetting
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 auditName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 auditLabel
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 boot
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Models;
4
5use App\Service\CacheService;
6use App\Support\Auditable;
7use Illuminate\Database\Eloquent\Model;
8
9/**
10 * A single stored setting value. Read/write through App\Services\Setting\
11 * SettingService (or the settings() helper) — not this model directly.
12 */
13class AppSetting extends Model
14{
15    use Auditable;
16
17    protected $table = 'app_settings';
18
19    protected $fillable = ['group', 'key', 'value'];
20
21    protected $casts = [
22        'value' => 'array',
23    ];
24
25    protected function auditName(): string
26    {
27        return 'setting';
28    }
29
30    protected function auditLabel(): ?string
31    {
32        return "{$this->group}.{$this->key}";
33    }
34
35    protected static function boot()
36    {
37        parent::boot();
38
39        static::saved(fn () => CacheService::forgetAppSettings());
40        static::deleted(fn () => CacheService::forgetAppSettings());
41    }
42}