Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
71.43% |
5 / 7 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Setting | |
71.43% |
5 / 7 |
|
0.00% |
0 / 1 |
1.02 | |
0.00% |
0 / 1 |
| boot | |
71.43% |
5 / 7 |
|
0.00% |
0 / 1 |
1.02 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use App\Service\CacheService; |
| 6 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 7 | use Illuminate\Database\Eloquent\Model; |
| 8 | |
| 9 | class Setting extends Model |
| 10 | { |
| 11 | use HasFactory; |
| 12 | |
| 13 | protected $table = 'settings'; |
| 14 | |
| 15 | protected $fillable = [ |
| 16 | 'name', |
| 17 | 'logo', |
| 18 | 'phone1', |
| 19 | 'phone2', |
| 20 | 'email', |
| 21 | 'address', |
| 22 | 'fb', |
| 23 | 'wp', |
| 24 | 'instagram', |
| 25 | 'youtube', |
| 26 | 'twitter', |
| 27 | ]; |
| 28 | |
| 29 | // CACHING: setting() helper caches this row (see MhHelper.php). Bust it |
| 30 | // immediately whenever the settings row is saved or deleted. |
| 31 | protected static function boot() |
| 32 | { |
| 33 | parent::boot(); |
| 34 | |
| 35 | static::saved(function () { |
| 36 | CacheService::forgetSetting(); |
| 37 | }); |
| 38 | |
| 39 | static::deleted(function () { |
| 40 | CacheService::forgetSetting(); |
| 41 | }); |
| 42 | } |
| 43 | } |