Issues (927)

src/Models/Admin/Career.php (9 issues)

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;
0 ignored issues
show
The type Spatie\Activitylog\LogOptions 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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
    public function __construct(array $attributes = [])
47
    {
48
        $this->table = config('website.table_prefix', 'website').'_careers';
49
50
        parent::__construct($attributes);
51
    }
52
53
    // Appends
54
    protected $casts = [
55
        'summary' => 'array',
56
    ];
57
58
    // Relationship
59
    public function applications()
60
    {
61
        return $this->hasMany(Application::class);
62
    }
63
64
    // Accessors
65
    public function getGroupAttribute($attribute)
66
    {
67
        return ! is_null($attribute) ? (config('website.career_group', [
68
            1 => 'REASEARCHERS/STAFF',
69
            2 => 'FIELD STAFF',
70
            3 => 'INTERN/VOLUNTEERS',
71
        ])[$attribute]) : null;
72
    }
73
74
    // Methods
75
    public function shortListed()
76
    {
77
        return Application::where('career_id', $this->id)->where('short_listed', 1)->latest()->get();
78
    }
79
80
    // Methods
81
    public function selected()
82
    {
83
        return Application::where('career_id', $this->id)->where('selected', 1)->latest()->get();
84
    }
85
86
    public function searchSchema()
87
    {
88
        $schema = Schema::jobPosting()
89
            ->title($this->name)
0 ignored issues
show
Bug Best Practice introduced by
The property name does not exist on Adminetic\Website\Models\Admin\Career. Did you maybe forget to declare it?
Loading history...
90
            ->name($this->name)
91
            ->url(route('website.career', ['career' => $this->slug]))
0 ignored issues
show
Bug Best Practice introduced by
The property slug does not exist on Adminetic\Website\Models\Admin\Career. Did you maybe forget to declare it?
Loading history...
92
            ->alternateName($this->designation)
0 ignored issues
show
Bug Best Practice introduced by
The property designation does not exist on Adminetic\Website\Models\Admin\Career. Did you maybe forget to declare it?
Loading history...
93
            ->jobLocation($this->location)
0 ignored issues
show
Bug Best Practice introduced by
The property location does not exist on Adminetic\Website\Models\Admin\Career. Did you maybe forget to declare it?
Loading history...
94
            ->baseSalary($this->salary)
0 ignored issues
show
Bug Best Practice introduced by
The property salary does not exist on Adminetic\Website\Models\Admin\Career. Did you maybe forget to declare it?
Loading history...
95
            ->datePosted($this->created_at)
96
            ->description($this->excerpt)
0 ignored issues
show
Bug Best Practice introduced by
The property excerpt does not exist on Adminetic\Website\Models\Admin\Career. Did you maybe forget to declare it?
Loading history...
97
            ->directApply(true)
98
            ->estimatedSalary($this->salary)
99
            ->occupationalCategory(config('website.career_group')[$this->group ?? 1]);
0 ignored issues
show
Bug Best Practice introduced by
The property group does not exist on Adminetic\Website\Models\Admin\Career. Did you maybe forget to declare it?
Loading history...
100
101
        return $schema->toScript();
102
    }
103
104
    // Accessors
105
    public function getImageAttribute()
106
    {
107
        return ! is_null($this->getFirstMedia('image')) ? $this->getFirstMediaUrl('image') : asset('adminetic/static/placeholder.jpg');
108
    }
109
}
110