Passed
Push — main ( 52a9ba...b89683 )
by PRATIK
04:37 queued 14s
created

Faq   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A cacheKey() 0 3 2
A boot() 0 14 1
A getActivitylogOptions() 0 3 1
1
<?php
2
3
namespace Adminetic\Website\Models\Admin;
4
5
use Spatie\Activitylog\LogOptions;
0 ignored issues
show
Bug introduced by
The type Spatie\Activitylog\LogOptions 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...
6
use Illuminate\Support\Facades\Cache;
7
use Illuminate\Database\Eloquent\Model;
8
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...
9
10
class Faq extends Model
11
{
12
    use LogsActivity;
13
14
    protected $guarded = [];
15
16
    // Forget cache on updating or saving and deleting
17
    public static function boot()
18
    {
19
        parent::boot();
20
21
        static::saving(function () {
22
            self::cacheKey();
23
        });
24
25
        static::deleting(function () {
26
            self::cacheKey();
27
        });
28
29
        Faq::creating(function ($model) {
30
            $model->position = Faq::max('position') + 1;
31
        });
32
    }
33
34
    // Cache Keys
35
    private static function cacheKey()
36
    {
37
        Cache::has('faqs') ? Cache::forget('faqs') : '';
38
    }
39
40
    // Logs
41
    protected static $logName = 'faq';
42
43
    public function getActivitylogOptions(): LogOptions
44
    {
45
        return LogOptions::defaults();
46
    }
47
}
48