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
|
40 |
|
public function groupsManaged() |
42
|
|
|
{ |
43
|
40 |
|
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
|
38 |
|
public function verifyGroup(Group $group) |
55
|
|
|
{ |
56
|
38 |
|
$group = $this->groupsManaged()->where('id', $group->id)->first(); |
57
|
|
|
|
58
|
38 |
|
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
|
18 |
|
public function verifyMeeting(Meeting $meeting) |
97
|
|
|
{ |
98
|
|
|
//TODO test this |
99
|
18 |
|
return $meeting->group->planner_id == $this->id; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param MeetingTimeslot $meetingTimeslot |
105
|
|
|
* @return bool |
106
|
|
|
*/ |
107
|
8 |
|
public function verifyMeetingTimeslot(MeetingTimeslot $meetingTimeslot) |
108
|
|
|
{ |
109
|
|
|
//TODO test this |
110
|
8 |
|
return $this->verifyMeeting($meetingTimeslot->meeting); |
|
|
|
|
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.