Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Theme | |
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
2.15 | |
0.00% |
0 / 1 |
| isDefault | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| booted | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use App\Service\CacheService; |
| 6 | use Illuminate\Database\Eloquent\Model; |
| 7 | |
| 8 | class Theme extends Model |
| 9 | { |
| 10 | protected $fillable = ['handle', 'name', 'version', 'is_active', 'settings']; |
| 11 | |
| 12 | protected $casts = [ |
| 13 | 'is_active' => 'boolean', |
| 14 | 'settings' => 'array', |
| 15 | ]; |
| 16 | |
| 17 | public const DEFAULT = 'default'; |
| 18 | |
| 19 | public function isDefault(): bool |
| 20 | { |
| 21 | return $this->handle === self::DEFAULT; |
| 22 | } |
| 23 | |
| 24 | protected static function booted(): void |
| 25 | { |
| 26 | static::saved(fn () => CacheService::forgetThemes()); |
| 27 | static::deleted(fn () => CacheService::forgetThemes()); |
| 28 | } |
| 29 | } |