1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Lionix\SeoManager\Models; |
4
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
|
|
|
6
|
|
|
|
7
|
|
|
class SeoManager extends Model |
8
|
|
|
{ |
9
|
|
|
protected $table; |
10
|
|
|
protected $locale; |
11
|
|
|
|
12
|
|
|
protected $fillable = [ |
13
|
|
|
'uri', |
14
|
|
|
'params', |
15
|
|
|
'mapping', |
16
|
|
|
'keywords', |
17
|
|
|
'description', |
18
|
|
|
'title', |
19
|
|
|
'author', |
20
|
|
|
'url', |
21
|
|
|
'title_dynamic', |
22
|
|
|
'og_data' |
23
|
|
|
]; |
24
|
|
|
|
25
|
|
|
protected $casts = [ |
26
|
|
|
'params' => 'array', |
27
|
|
|
'mapping' => 'array', |
28
|
|
|
'keywords' => 'array', |
29
|
|
|
'title_dynamic' => 'array', |
30
|
|
|
'og_data' => 'array', |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
public function __construct() |
34
|
|
|
{ |
35
|
|
|
$this->table = config('seo-manager.database.table'); |
|
|
|
|
36
|
|
|
$this->locale = app()->getLocale(); |
|
|
|
|
37
|
|
|
|
38
|
|
|
parent::__construct(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function translation() |
42
|
|
|
{ |
43
|
|
|
return $this->hasOne(Translate::class, 'route_id', 'id')->where('locale', app()->getLocale()); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
private function isNotDefaultLocale() |
47
|
|
|
{ |
48
|
|
|
return $this->locale !== config('seo-manager.locale') && $this->has('translation'); |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getKeywordsAttribute($value) |
52
|
|
|
{ |
53
|
|
|
if ($this->isNotDefaultLocale() && !empty(optional($this->translation)->keywords)) { |
54
|
|
|
return $this->translation->keywords; |
55
|
|
|
} |
56
|
|
|
return json_decode($value); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function getDescriptionAttribute($value) |
60
|
|
|
{ |
61
|
|
|
if ($this->isNotDefaultLocale() && !is_null(optional($this->translation)->description)) { |
62
|
|
|
return $this->translation->description; |
63
|
|
|
} |
64
|
|
|
return $value; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function getTitleAttribute($value) |
68
|
|
|
{ |
69
|
|
|
if ($this->isNotDefaultLocale() && !is_null(optional($this->translation)->title)) { |
70
|
|
|
return $this->translation->title; |
71
|
|
|
} |
72
|
|
|
return $value; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function getAuthorAttribute($value) |
76
|
|
|
{ |
77
|
|
|
if ($this->isNotDefaultLocale() && !is_null(optional($this->translation)->author)) { |
78
|
|
|
return $this->translation->author; |
79
|
|
|
} |
80
|
|
|
return $value; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function getUrlAttribute($value) |
84
|
|
|
{ |
85
|
|
|
if ($this->isNotDefaultLocale() && !is_null(optional($this->translation)->url)) { |
86
|
|
|
return $this->translation->url; |
87
|
|
|
} |
88
|
|
|
return $value; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function getTitleDynamicAttribute($value) |
92
|
|
|
{ |
93
|
|
|
if ($this->isNotDefaultLocale() && !empty(optional($this->translation)->title_dynamic)) { |
94
|
|
|
return $this->translation->title_dynamic; |
95
|
|
|
} |
96
|
|
|
return json_decode($value); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function getOgDataAttribute($value) |
100
|
|
|
{ |
101
|
|
|
if ($this->isNotDefaultLocale() && !is_null(optional($this->translation)->og_data)) { |
102
|
|
|
return $this->translation->og_data; |
103
|
|
|
} |
104
|
|
|
return json_decode($value, true); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
} |
108
|
|
|
|
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