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
|
|
|
use Spatie\SchemaOrg\Schema; |
12
|
|
|
|
13
|
|
|
class Service extends Model implements HasMedia |
14
|
|
|
{ |
15
|
|
|
use LogsActivity, InteractsWithMedia; |
16
|
|
|
|
17
|
|
|
protected $guarded = []; |
18
|
|
|
|
19
|
|
|
// Forget cache on updating or saving and deleting |
20
|
|
|
public static function boot() |
21
|
|
|
{ |
22
|
|
|
parent::boot(); |
23
|
|
|
|
24
|
|
|
static::saving(function () { |
25
|
|
|
self::cacheKey(); |
26
|
|
|
}); |
27
|
|
|
|
28
|
|
|
static::deleting(function () { |
29
|
|
|
self::cacheKey(); |
30
|
|
|
}); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
// Cache Keys |
34
|
|
|
private static function cacheKey() |
35
|
|
|
{ |
36
|
|
|
Cache::has('services') ? Cache::forget('services') : ''; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
// Logs |
40
|
|
|
protected static $logName = 'service'; |
41
|
|
|
|
42
|
|
|
public function getActivitylogOptions(): LogOptions |
43
|
|
|
{ |
44
|
|
|
return LogOptions::defaults(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
protected $casts = [ |
48
|
|
|
'data' => 'array', |
49
|
|
|
]; |
50
|
|
|
|
51
|
|
|
public function __construct(array $attributes = []) |
52
|
|
|
{ |
53
|
|
|
$this->table = config('website.table_prefix', 'website') . '_services'; |
54
|
|
|
|
55
|
|
|
parent::__construct($attributes); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
// Relationships |
60
|
|
|
public function category() |
61
|
|
|
{ |
62
|
|
|
return $this->belongsTo(Category::class); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function inquiries() |
66
|
|
|
{ |
67
|
|
|
return $this->hasMany(Inquiry::class); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
// Scopes |
71
|
|
|
public function scopePosition($qry) |
72
|
|
|
{ |
73
|
|
|
return $qry->orderBy('position'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function scopeActive($qry) |
77
|
|
|
{ |
78
|
|
|
return $qry->where('active', 1); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function scopeFeatured($qry) |
82
|
|
|
{ |
83
|
|
|
return $qry->where('featured', 1); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function searchSchema() |
87
|
|
|
{ |
88
|
|
|
$schema = Schema::service() |
89
|
|
|
->name($this->meta_name ?? $this->name) |
|
|
|
|
90
|
|
|
->description($this->meta_description ?? $this->excerpt) |
|
|
|
|
91
|
|
|
->url(route('website.service', ['service' => $this->slug])) |
|
|
|
|
92
|
|
|
->keywords($this->meta_keywords); |
|
|
|
|
93
|
|
|
|
94
|
|
|
return $schema->toScript(); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
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