Job_title.php
1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Job_title extends Model
{
use HasFactory;
protected $fillable = [
'name',
'is_remove',
'parent_id',
'sort',
'position_id',
'is_bd'
];
/*
* Связь модели Вакансии (Ad_employer) с моделью Должности (Job_title)
*/
public function Ads() {
return $this->belongsToMany(Ad_employer::class, 'ad_jobs');
}
/*
* Связь таблицы job_titles с таблицей job_titles через ключ parent_id
многие-к-одному
*/
public function parent() {
return $this->belongsTo(Job_title::class, 'parent_id');
}
/*
* Связь модели Вакансии (Job_title) с моделью Вакансии работника (worker_jobs)
один-ко-многим
*/
public function worker_job() {
return $this->hasMany(worker_jobs::class);
}
public function scopeActive($query) {
return $query->where('is_remove', '=', '0');
}
public function scopeBdif($query) {
return $query->where(function($q) {
$q->where('is_bd', '1')->orwhere('is_bd', '2');
});
}
public function scopeNotbdif($query) {
return $query->where(function($q) {
$q->where('is_bd', '0')->orwhere('is_bd', '2');
});
}
}