Passed
Push — main ( 709496...6259dd )
by PRATIK
04:09
created

Data   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getActivitylogOptions() 0 3 1
A cacheKey() 0 3 2
A boot() 0 10 1
1
<?php
2
3
namespace Pratiksh\Adminetic\Models\Admin;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Facades\Cache;
7
use Spatie\Activitylog\LogOptions;
8
use Spatie\Activitylog\Traits\LogsActivity;
9
10
class Data extends Model
11
{
12
    use LogsActivity;
0 ignored issues
show
introduced by
The trait Spatie\Activitylog\Traits\LogsActivity requires some properties which are not provided by Pratiksh\Adminetic\Models\Admin\Data: $submitEmptyLogs, $name, $logExceptAttributes, $attributeRawValues, $dontLogIfAttributesChangedOnly, $descriptionForEvent, $logOnlyDirty, $logFillable, $value, $logUnguarded, $logAttributes
Loading history...
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
30
    // Cache Keys
31
    private static function cacheKey()
32
    {
33
        Cache::has('data') ? Cache::forget('data') : '';
34
    }
35
36
    // Logs
37
    protected static $logName = 'data';
38
39
    public function getActivitylogOptions(): LogOptions
40
    {
41
        return LogOptions::defaults();
42
    }
43
}
44