1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace plunner; |
4
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent\Model; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Group |
9
|
|
|
* |
10
|
|
|
* @author Claudio Cardinale <[email protected]> |
11
|
|
|
* @copyright 2015 Claudio Cardinale |
12
|
|
|
* @version 1.0.0 |
13
|
|
|
* @package plunner |
14
|
|
|
* @property integer $id |
15
|
|
|
* @property \Carbon\Carbon $created_at |
16
|
|
|
* @property \Carbon\Carbon $updated_at |
17
|
|
|
* @property string $name |
18
|
|
|
* @property string $description |
19
|
|
|
* @property integer $company_id |
20
|
|
|
* @property integer $planner_id |
21
|
|
|
* @property-read mixed $planner_name |
22
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Employee[] $employees |
23
|
|
|
* @property-read \plunner\Planner $planner |
24
|
|
|
* @property-read \plunner\Company $company |
25
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Meeting[] $meetings |
26
|
|
|
*/ |
27
|
|
|
class Group extends Model |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* The attributes that are mass assignable. |
31
|
|
|
* |
32
|
|
|
* @var array |
33
|
|
|
*/ |
34
|
|
|
protected $fillable = ['name', 'description', 'planner_id']; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var array |
38
|
|
|
*/ |
39
|
|
|
protected $hidden = ['planner', 'pivot']; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var array |
43
|
|
|
*/ |
44
|
|
|
protected $appends = ['planner_name']; |
45
|
|
|
|
46
|
54 |
|
public function getPlannerNameAttribute() |
47
|
|
|
{ |
48
|
54 |
|
if (is_object($this->planner) && $this->planner->exists) |
49
|
53 |
|
return $this->planner->name; |
50
|
2 |
|
return null; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
55
|
|
|
*/ |
56
|
48 |
|
public function employees() |
57
|
|
|
{ |
58
|
48 |
|
return $this->belongsToMany(Employee::class); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
63
|
|
|
*/ |
64
|
141 |
|
public function planner() |
65
|
|
|
{ |
66
|
141 |
|
return $this->belongsTo(Planner::class); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
71
|
|
|
*/ |
72
|
|
|
public function company() |
73
|
|
|
{ |
74
|
|
|
return $this->belongsTo(Company::class); |
75
|
|
|
} |
76
|
|
|
|
77
|
117 |
|
public function meetings() |
78
|
|
|
{ |
79
|
117 |
|
return $this->hasMany(Meeting::class); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|