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