1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Adminetic\Website\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
|
|
|
use Spatie\MediaLibrary\HasMedia; |
|
|
|
|
10
|
|
|
use Spatie\MediaLibrary\InteractsWithMedia; |
|
|
|
|
11
|
|
|
|
12
|
|
|
class Notice extends Model implements HasMedia |
13
|
|
|
{ |
14
|
|
|
use LogsActivity, InteractsWithMedia; |
15
|
|
|
|
16
|
|
|
protected $guarded = []; |
17
|
|
|
|
18
|
|
|
// Forget cache on updating or saving and deleting |
19
|
|
|
public static function boot() |
20
|
|
|
{ |
21
|
|
|
parent::boot(); |
22
|
|
|
|
23
|
|
|
static::saving(function () { |
24
|
|
|
self::cacheKey(); |
25
|
|
|
}); |
26
|
|
|
|
27
|
|
|
static::deleting(function () { |
28
|
|
|
self::cacheKey(); |
29
|
|
|
}); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
// Cache Keys |
33
|
|
|
private static function cacheKey() |
34
|
|
|
{ |
35
|
|
|
Cache::has('notices') ? Cache::forget('notices') : ''; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
// Logs |
39
|
|
|
protected static $logName = 'notice'; |
40
|
|
|
|
41
|
|
|
public function getActivitylogOptions(): LogOptions |
42
|
|
|
{ |
43
|
|
|
return LogOptions::defaults(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
protected $casts = [ |
47
|
|
|
'data' => 'array', |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
public function __construct(array $attributes = []) |
51
|
|
|
{ |
52
|
|
|
$this->table = config('website.table_prefix', 'website').'_notices'; |
53
|
|
|
|
54
|
|
|
parent::__construct($attributes); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
// Relationships |
58
|
|
|
public function category() |
59
|
|
|
{ |
60
|
|
|
return $this->belongsTo(Category::class); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
// Scopes |
64
|
|
|
public function scopePosition($qry) |
65
|
|
|
{ |
66
|
|
|
return $qry->orderBy('position'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function scopeActive($qry) |
70
|
|
|
{ |
71
|
|
|
return $qry->where('active', 1); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function scopePopup($qry) |
75
|
|
|
{ |
76
|
|
|
return $qry->where('popup', 1); |
77
|
|
|
} |
78
|
|
|
// Accessors |
79
|
|
|
public function getImageAttribute() |
80
|
|
|
{ |
81
|
|
|
return ! is_null($this->getFirstMedia('image')) ? $this->getFirstMediaUrl('image') : asset('adminetic/static/placeholder.jpg'); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function getIconImageAttribute() |
85
|
|
|
{ |
86
|
|
|
return ! is_null($this->getFirstMedia('icon_image')) ? $this->getFirstMediaUrl('icon_image') : asset('adminetic/static/placeholder.jpg'); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths