Job_title.php
906 Bytes
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
<?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'
];
/*
* Связь модели Вакансии (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');
}
public function scopeActive($query) {
return $query->where('is_remove', '=', '0');
}
}