1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace plunner; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Class Planner |
8
|
|
|
* |
9
|
|
|
* @author Claudio Cardinale <[email protected]> |
10
|
|
|
* @copyright 2015 Claudio Cardinale |
11
|
|
|
* @version 1.0.0 |
12
|
|
|
* @package plunner |
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 mixed $is_planner |
22
|
|
|
* @property-read \plunner\Company $company |
23
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Group[] $groups |
24
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Calendar[] $calendars |
25
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Meeting[] $meetings |
26
|
|
|
*/ |
27
|
|
|
class Planner extends Employee |
28
|
|
|
{ |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param Group $group |
32
|
|
|
* @return bool |
33
|
|
|
*/ |
34
|
38 |
|
public function verifyGroup(Group $group) |
35
|
|
|
{ |
36
|
38 |
|
$group = $this->groupsManaged()->where('id', $group->id)->first(); |
37
|
|
|
|
38
|
38 |
|
return (is_object($group) && $group->exists); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/* |
42
|
|
|
* for a planer employee the policyCheckable methods say if the planer can modify or not that part |
43
|
|
|
*/ |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany |
47
|
|
|
*/ |
48
|
40 |
|
public function groupsManaged() |
49
|
|
|
{ |
50
|
40 |
|
return $this->groupsManagedRelationship(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param Employee $employee |
55
|
|
|
* @return bool |
56
|
|
|
*/ |
57
|
|
|
public function verifyEmployee(Employee $employee) |
58
|
|
|
{ |
59
|
|
|
$group = $this->groupsManaged()->whereHas('employees', function ($query) use ($employee) { |
60
|
|
|
$query->where('employees.id', $employee->id); |
61
|
|
|
})->first(); |
62
|
|
|
|
63
|
|
|
return (is_object($group) && $group->exists); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param Company $company |
68
|
|
|
* @return bool |
69
|
|
|
*/ |
70
|
|
|
public function verifyCompany(Company $company) |
71
|
|
|
{ |
72
|
|
|
return false; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* the employee can see a calendar |
77
|
|
|
* @param Calendar $calendar |
78
|
|
|
* @return bool |
79
|
|
|
*/ |
80
|
|
|
public function verifyCalendar(Calendar $calendar) |
81
|
|
|
{ |
82
|
|
|
//TODO implement and test |
83
|
|
|
return false; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param Timeslot $timeslot |
88
|
|
|
* @return bool |
89
|
|
|
*/ |
90
|
|
|
public function verifyTimeslot(Timeslot $timeslot) |
91
|
|
|
{ |
92
|
|
|
//TODO implement and test this |
93
|
|
|
return false; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param MeetingTimeslot $meetingTimeslot |
98
|
|
|
* @return bool |
99
|
|
|
*/ |
100
|
8 |
|
public function verifyMeetingTimeslot(MeetingTimeslot $meetingTimeslot) |
101
|
|
|
{ |
102
|
|
|
//TODO test this |
103
|
8 |
|
return $this->verifyMeeting($meetingTimeslot->meeting); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @param Meeting $meeting |
108
|
|
|
* @return bool |
109
|
|
|
*/ |
110
|
18 |
|
public function verifyMeeting(Meeting $meeting) |
111
|
|
|
{ |
112
|
|
|
//TODO test this |
113
|
18 |
|
return $meeting->group->planner_id == $this->id; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|