1 | <?php |
||
41 | class Employee extends Model implements AuthenticatableContract, |
||
42 | AuthorizableContract, |
||
43 | CanResetPasswordContract, |
||
44 | PolicyCheckable |
||
45 | { |
||
46 | use Authenticatable, Authorizable, CanResetPassword; |
||
47 | |||
48 | /** |
||
49 | * The attributes that are mass assignable. |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | protected $fillable = ['name', 'email', 'password']; |
||
54 | |||
55 | /** |
||
56 | * The attributes excluded from the model's JSON form. |
||
57 | * |
||
58 | * @var array |
||
59 | */ |
||
60 | protected $hidden = ['password', 'remember_token', 'pivot']; |
||
61 | |||
62 | /** |
||
63 | * @var array |
||
64 | */ |
||
65 | protected $appends = ['is_planner']; |
||
66 | |||
67 | 23 | public function getIsPlannerAttribute() |
|
71 | |||
72 | /** |
||
73 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
74 | */ |
||
75 | 2 | public function company() |
|
79 | |||
80 | /** |
||
81 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
82 | */ |
||
83 | 46 | public function groups() |
|
87 | |||
88 | /** |
||
89 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
90 | */ |
||
91 | 14 | public function calendars() |
|
95 | |||
96 | /** |
||
97 | * meetings where the user participates |
||
98 | * to get all meetings where the user can go user groups with meetings |
||
99 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
100 | */ |
||
101 | 2 | public function meetings(){ |
|
102 | //TODO durign the inserting chek if the meeting is of a group of the user |
||
103 | 2 | return $this->belongsToMany(Meeting::class); |
|
104 | } |
||
105 | |||
106 | /** |
||
107 | * Get the e-mail address where password reset links are sent. |
||
108 | * This is needed for multiple user type login |
||
109 | * |
||
110 | * Make email unique |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | 2 | public function getEmailForPasswordReset() |
|
128 | |||
129 | /** |
||
130 | * @param Group $group |
||
131 | * @return bool |
||
132 | */ |
||
133 | 8 | public function belongsToGroup(Group $group) |
|
138 | |||
139 | /* |
||
140 | * for a normal employee the policyCheckable methods say if the employee can se or not the element |
||
141 | */ |
||
142 | |||
143 | /** |
||
144 | * @param Group $group |
||
145 | * @return bool |
||
146 | */ |
||
147 | 4 | public function verifyGroup(Group $group) |
|
151 | |||
152 | /** |
||
153 | * @param Employee $employee |
||
154 | * @return bool |
||
155 | */ |
||
156 | public function verifyEmployee(Employee $employee) |
||
160 | |||
161 | /** |
||
162 | * @param Company $company |
||
163 | * @return bool |
||
164 | */ |
||
165 | public function verifyCompany(Company $company) |
||
169 | |||
170 | /** |
||
171 | * the employee can modify a calendar |
||
172 | * @param Calendar $calendar |
||
173 | * @return bool |
||
174 | */ |
||
175 | 8 | public function verifyCalendar(Calendar $calendar) |
|
180 | |||
181 | /** |
||
182 | * @param Meeting $meeting |
||
183 | * @return bool |
||
184 | */ |
||
185 | public function verifyMeeting(Meeting $meeting) |
||
190 | |||
191 | /** |
||
192 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
193 | */ |
||
194 | 49 | protected function groupsManagedRelationship() |
|
198 | } |
||
199 |