1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Created by Reliese Model. |
5
|
|
|
* Date: Thu, 12 Jul 2018 22:39:27 +0000. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace App\Models\Lookup; |
9
|
|
|
|
10
|
|
|
use App\Models\BaseModel; |
11
|
|
|
|
12
|
|
|
use Backpack\CRUD\app\Models\Traits\CrudTrait; |
13
|
|
|
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class Department |
17
|
|
|
* @property int $id |
18
|
|
|
* @property string $name |
19
|
|
|
* @property string $impact |
20
|
|
|
* @property string $preference |
21
|
|
|
* |
22
|
|
|
* @property \Jenssegers\Date\Date $created_at |
23
|
|
|
* @property \Jenssegers\Date\Date $updated_at |
24
|
|
|
* |
25
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $managers |
26
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $job_posters |
27
|
|
|
* |
28
|
|
|
* Localized Properties: |
29
|
|
|
* @property string $name |
30
|
|
|
* @property string $impact |
31
|
|
|
* @property string $preference |
32
|
|
|
* |
33
|
|
|
* Methods |
34
|
|
|
* @method mixed[] toApiArray() |
35
|
|
|
*/ |
36
|
|
|
class Department extends BaseModel |
37
|
|
|
{ |
38
|
|
|
use CrudTrait; |
|
|
|
|
39
|
|
|
use HasTranslations; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var $translatable string[] |
|
|
|
|
43
|
|
|
* */ |
44
|
|
|
public $translatable = [ |
45
|
|
|
'name', |
46
|
|
|
'impact', |
47
|
|
|
'preference', |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var $fillable string[] |
|
|
|
|
52
|
|
|
* */ |
53
|
|
|
protected $fillable = [ |
54
|
|
|
'name', |
55
|
|
|
'impact', |
56
|
|
|
'preference', |
57
|
|
|
]; |
58
|
|
|
|
59
|
|
|
public function managers() // phpcs:ignore |
60
|
|
|
{ |
61
|
|
|
return $this->hasMany(\App\Models\Manager::class); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function department_translations() // phpcs:ignore |
65
|
|
|
{ |
66
|
|
|
return $this->hasMany(\App\Models\Lookup\DepartmentTranslation::class); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function job_posters() // phpcs:ignore |
70
|
|
|
{ |
71
|
|
|
return $this->hasMany(\App\Models\JobPoster::class); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Return the array of values used to represent this object in an api response. |
76
|
|
|
* |
77
|
|
|
* @return mixed[] |
78
|
|
|
*/ |
79
|
|
|
public function toApiArray() |
|
|
|
|
80
|
|
|
{ |
81
|
|
|
$deptArray = ['id' => $this->id]; |
82
|
|
|
foreach (['en', 'fr'] as $locale) { |
83
|
|
|
$deptArray[$locale] = [ |
84
|
|
|
'name' => $this->getTranslation('name', $locale), |
85
|
|
|
'impact' => $this->getTranslation('impact', $locale), |
86
|
|
|
]; |
87
|
|
|
} |
88
|
|
|
return $deptArray; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|