Passed
Push — main ( 3cfdb8...a45320 )
by PRATIK
10:34
created

Template::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 5
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
namespace Adminetic\Website\Models\Admin;
4
5
use Illuminate\Support\Facades\Cache;
6
use Illuminate\Database\Eloquent\Model;
7
use Spatie\Activitylog\Traits\LogsActivity;
0 ignored issues
show
Bug introduced by
The type Spatie\Activitylog\Traits\LogsActivity was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
class Template extends Model
10
{
11
    use LogsActivity;
12
13
    protected $guarded = [];
14
15
    // Forget cache on updating or saving and deleting
16
    public static function boot()
17
    {
18
        parent::boot();
19
20
        static::saving(function () {
21
            self::cacheKey();
22
        });
23
24
        static::deleting(function () {
25
            self::cacheKey();
26
        });
27
    }
28
29
    // Cache Keys
30
    private static function cacheKey()
31
    {
32
        Cache::has('templates') ? Cache::forget('templates') : '';
33
    }
34
35
    // Logs
36
    protected static $logName = 'template';
37
}
38