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\SchemaOrg\Schema; |
10
|
|
|
|
11
|
|
|
class Career extends Model |
12
|
|
|
{ |
13
|
|
|
use LogsActivity; |
14
|
|
|
|
15
|
|
|
protected $guarded = []; |
16
|
|
|
|
17
|
|
|
// Forget cache on updating or saving and deleting |
18
|
|
|
public static function boot() |
19
|
|
|
{ |
20
|
|
|
parent::boot(); |
21
|
|
|
|
22
|
|
|
static::saving(function () { |
23
|
|
|
self::cacheKey(); |
24
|
|
|
}); |
25
|
|
|
|
26
|
|
|
static::deleting(function () { |
27
|
|
|
self::cacheKey(); |
28
|
|
|
}); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
// Cache Keys |
32
|
|
|
private static function cacheKey() |
33
|
|
|
{ |
34
|
|
|
Cache::has('careers') ? Cache::forget('careers') : ''; |
35
|
|
|
Cache::has('latest_careers') ? Cache::forget('latest_careers') : ''; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
// Logs |
39
|
|
|
protected static $logName = 'career'; |
40
|
|
|
|
41
|
|
|
public function getActivitylogOptions(): LogOptions |
42
|
|
|
{ |
43
|
|
|
return LogOptions::defaults(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
public function __construct(array $attributes = []) |
48
|
|
|
{ |
49
|
|
|
$this->table = config('website.table_prefix', 'website') . '_careers'; |
50
|
|
|
|
51
|
|
|
parent::__construct($attributes); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
// Appends |
55
|
|
|
protected $casts = [ |
56
|
|
|
'summary' => 'array', |
57
|
|
|
]; |
58
|
|
|
|
59
|
|
|
// Relationship |
60
|
|
|
public function applications() |
61
|
|
|
{ |
62
|
|
|
return $this->hasMany(Application::class); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
// Accessors |
66
|
|
|
public function getGroupAttribute($attribute) |
67
|
|
|
{ |
68
|
|
|
return !is_null($attribute) ? (config('website.career_group', [ |
69
|
|
|
1 => 'REASEARCHERS/STAFF', |
70
|
|
|
2 => 'FIELD STAFF', |
71
|
|
|
3 => 'INTERN/VOLUNTEERS', |
72
|
|
|
])[$attribute]) : null; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
// Methods |
76
|
|
|
public function shortListed() |
77
|
|
|
{ |
78
|
|
|
return Application::where('career_id', $this->id)->where('short_listed', 1)->latest()->get(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
// Methods |
82
|
|
|
public function selected() |
83
|
|
|
{ |
84
|
|
|
return Application::where('career_id', $this->id)->where('selected', 1)->latest()->get(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function searchSchema() |
88
|
|
|
{ |
89
|
|
|
$schema = Schema::jobPosting() |
90
|
|
|
->title($this->name) |
|
|
|
|
91
|
|
|
->name($this->name) |
92
|
|
|
->url(route('website.career', ['career' => $this->slug])) |
|
|
|
|
93
|
|
|
->alternateName($this->designation) |
|
|
|
|
94
|
|
|
->jobLocation($this->location) |
|
|
|
|
95
|
|
|
->baseSalary($this->salary) |
|
|
|
|
96
|
|
|
->datePosted($this->created_at) |
97
|
|
|
->description($this->excerpt) |
|
|
|
|
98
|
|
|
->directApply(true) |
99
|
|
|
->estimatedSalary($this->salary) |
100
|
|
|
->occupationalCategory(config('website.career_group')[$this->group ?? 1]); |
|
|
|
|
101
|
|
|
|
102
|
|
|
return $schema->toScript(); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
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