1 | <?php |
||
2 | |||
3 | namespace Adminetic\Announcement\Models\Admin; |
||
4 | |||
5 | use App\Models\User; |
||
0 ignored issues
–
show
|
|||
6 | use Illuminate\Database\Eloquent\Model; |
||
7 | use Illuminate\Support\Facades\Cache; |
||
8 | use Spatie\Activitylog\Traits\LogsActivity; |
||
0 ignored issues
–
show
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
9 | |||
10 | class Announcement extends Model |
||
11 | { |
||
12 | use LogsActivity; |
||
13 | |||
14 | protected $guarded = []; |
||
15 | |||
16 | // Forget cache on updating or saving and deleting |
||
17 | public static function boot() |
||
18 | { |
||
19 | parent::boot(); |
||
20 | |||
21 | static::saving(function () { |
||
22 | self::cacheKey(); |
||
23 | }); |
||
24 | |||
25 | static::deleting(function () { |
||
26 | self::cacheKey(); |
||
27 | }); |
||
28 | } |
||
29 | |||
30 | // Cache Keys |
||
31 | private static function cacheKey() |
||
32 | { |
||
33 | Cache::has('announcements') ? Cache::forget('announcements') : ''; |
||
34 | } |
||
35 | |||
36 | // Logs |
||
37 | protected static $logName = 'announcement'; |
||
38 | |||
39 | // Appends |
||
40 | protected $appends = ['audience_names', 'color']; |
||
41 | |||
42 | // Casts |
||
43 | protected $casts = [ |
||
44 | 'medium' => 'array', |
||
45 | 'audience' => 'array', |
||
46 | ]; |
||
47 | |||
48 | // Relation |
||
49 | public function user() |
||
50 | { |
||
51 | return $this->belongsTo(User::class, 'user_id'); |
||
52 | } |
||
53 | |||
54 | // Accessors |
||
55 | public function getAudienceNamesAttribute() |
||
56 | { |
||
57 | return User::find($this->audience)->pluck('name')->toArray(); |
||
58 | } |
||
59 | |||
60 | public function getColorAttribute() |
||
61 | { |
||
62 | $colors = ['primary', 'secondary', 'success', 'info', 'warning', 'danger', 'pink', 'grey']; |
||
63 | |||
64 | return $colors[array_rand($colors, 1)]; |
||
65 | } |
||
66 | |||
67 | public function mediums() |
||
68 | { |
||
69 | if (isset($this->medium)) { |
||
70 | foreach ($this->medium as $val) { |
||
71 | $mediums[] = [ |
||
72 | 1 => 'database', |
||
73 | 2 => 'mail', |
||
74 | ][$val]; |
||
75 | } |
||
76 | |||
77 | return $mediums; |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
78 | } else { |
||
79 | return null; |
||
80 | } |
||
81 | } |
||
82 | } |
||
83 |
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