Passed
Push — main ( 86a6dd...ec1f24 )
by PRATIK
03:12
created

Event   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 10 1
A cacheKey() 0 3 2
A gallery() 0 3 1
1
<?php
2
3
namespace Adminetic\Website\Models\Admin;
4
5
use Illuminate\Support\Facades\Cache;
6
use drh2so4\Thumbnail\Traits\Thumbnail;
0 ignored issues
show
Bug introduced by
The type drh2so4\Thumbnail\Traits\Thumbnail 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...
7
use Illuminate\Database\Eloquent\Model;
8
use Adminetic\Website\Models\Admin\Gallery;
9
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...
10
11
class Event extends Model
12
{
13
    use LogsActivity, Thumbnail;
14
15
    protected $guarded = [];
16
17
    // Forget cache on updating or saving and deleting
18
    public static function boot()
19
    {
20
        parent::boot();
21
22
        static::saving(function () {
23
            self::cacheKey();
24
        });
25
26
        static::deleting(function () {
27
            self::cacheKey();
28
        });
29
    }
30
31
    // Cache Keys
32
    private static function cacheKey()
33
    {
34
        Cache::has('events') ? Cache::forget('events') : '';
35
    }
36
37
    // Logs
38
    protected static $logName = 'event';
39
40
    // Casts
41
    protected $casts = [
42
        'meta_keywords' => 'array'
43
    ];
44
45
    // Relation
46
    public function gallery()
47
    {
48
        return $this->belongsTo(Gallery::class, 'gallery_id');
49
    }
50
}
51