|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace plunner; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class Planner |
|
8
|
|
|
* |
|
9
|
|
|
* @package plunner |
|
10
|
|
|
* @author Claudio Cardinale <[email protected]> |
|
11
|
|
|
* @copyright 2015 Claudio Cardinale |
|
12
|
|
|
* @version 1.0.0 |
|
13
|
|
|
* @property integer $id |
|
14
|
|
|
* @property string $name |
|
15
|
|
|
* @property string $email |
|
16
|
|
|
* @property string $password |
|
17
|
|
|
* @property integer $company_id |
|
18
|
|
|
* @property string $remember_token |
|
19
|
|
|
* @property \Carbon\Carbon $created_at |
|
20
|
|
|
* @property \Carbon\Carbon $updated_at |
|
21
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Group[] $groupsManaged |
|
22
|
|
|
* @property-read \plunner\Company $company |
|
23
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Group[] $groups |
|
24
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Meeting[] $meetings |
|
25
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Calendar[] $calendars |
|
26
|
|
|
* @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereId($value) |
|
27
|
|
|
* @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereName($value) |
|
28
|
|
|
* @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereEmail($value) |
|
29
|
|
|
* @method static \Illuminate\Database\Query\Builder|\plunner\Planner wherePassword($value) |
|
30
|
|
|
* @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereCompanyId($value) |
|
31
|
|
|
* @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereRememberToken($value) |
|
32
|
|
|
* @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereCreatedAt($value) |
|
33
|
|
|
* @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereUpdatedAt($value) |
|
34
|
|
|
*/ |
|
35
|
|
|
class Planner extends Employee |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
40
|
|
|
*/ |
|
41
|
26 |
|
public function groupsManaged() |
|
42
|
|
|
{ |
|
43
|
26 |
|
return $this->groupsManagedRelationship(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/* |
|
47
|
|
|
* for a planer employee the policyCheckable methods say if the planer can modify or not that part |
|
48
|
|
|
*/ |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param Group $group |
|
52
|
|
|
* @return bool |
|
53
|
|
|
*/ |
|
54
|
24 |
|
public function verifyGroup(Group $group) |
|
55
|
|
|
{ |
|
56
|
24 |
|
$group = $this->groupsManaged()->where('id', $group->id)->first(); |
|
57
|
|
|
|
|
58
|
24 |
|
return (is_object($group) && $group->exists); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param Employee $employee |
|
63
|
|
|
* @return bool |
|
64
|
|
|
*/ |
|
65
|
|
|
public function verifyEmployee(Employee $employee) |
|
66
|
|
|
{ |
|
67
|
|
|
$group = $this->groupsManaged()->whereHas('employees',function ($query) use ($employee) {$query->where('employees.id', $employee->id);})->first(); |
|
68
|
|
|
|
|
69
|
|
|
return (is_object($group) && $group->exists); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param Company $company |
|
74
|
|
|
* @return bool |
|
75
|
|
|
*/ |
|
76
|
|
|
public function verifyCompany(Company $company) |
|
77
|
|
|
{ |
|
78
|
|
|
return false; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* the employee can see a calendar |
|
83
|
|
|
* @param Calendar $calendar |
|
84
|
|
|
* @return bool |
|
85
|
|
|
*/ |
|
86
|
|
|
public function verifyCalendar(Calendar $calendar) |
|
87
|
|
|
{ |
|
88
|
|
|
//TODO implement and test |
|
89
|
|
|
return false; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param Meeting $meeting |
|
94
|
|
|
* @return bool |
|
95
|
|
|
*/ |
|
96
|
15 |
|
public function verifyMeeting(Meeting $meeting) |
|
97
|
|
|
{ |
|
98
|
|
|
//TODO test this |
|
99
|
15 |
|
return $meeting->group->planner_id == $this->id; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
} |
|
103
|
|
|
|