1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace plunner\Policies; |
4
|
|
|
|
5
|
|
|
use plunner\Company; |
6
|
|
|
use plunner\Employee; |
7
|
|
|
|
8
|
|
|
class EmployeePolicy |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Create a new policy instance. |
12
|
|
|
* |
13
|
|
|
* @return void |
|
|
|
|
14
|
|
|
*/ |
15
|
4 |
|
public function __construct() |
16
|
|
|
{ |
17
|
|
|
// |
18
|
4 |
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @param Company $company |
22
|
|
|
* @param Employee $employee |
23
|
|
|
* @return bool |
24
|
|
|
*/ |
25
|
|
|
public function index(Company $company, Employee $employee) |
26
|
|
|
{ |
27
|
|
|
return $this->userCheck($company, $employee); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param Company $company |
32
|
|
|
* @param Employee $employee |
33
|
|
|
* @return bool |
34
|
|
|
*/ |
35
|
|
|
public function store(Company $company, Employee $employee) |
36
|
|
|
{ |
37
|
|
|
return $this->userCheck($company, $employee); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param Company $company |
42
|
|
|
* @param Employee $employee |
43
|
|
|
* @return bool |
44
|
|
|
*/ |
45
|
1 |
|
public function update(Company $company, Employee $employee) |
46
|
|
|
{ |
47
|
1 |
|
return $this->userCheck($company, $employee); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param Company $company |
52
|
|
|
* @param Employee $employee |
53
|
|
|
* @return bool |
54
|
|
|
*/ |
55
|
2 |
|
public function show(Company $company, Employee $employee) |
56
|
|
|
{ |
57
|
2 |
|
return $this->userCheck($company, $employee); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param Company $company |
62
|
|
|
* @param Employee $employee |
63
|
|
|
* @return bool |
64
|
|
|
*/ |
65
|
2 |
|
public function destroy(Company $company, Employee $employee) |
66
|
|
|
{ |
67
|
2 |
|
return $this->userCheck($company, $employee); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param Company $company |
72
|
|
|
* @param Employee $employee |
73
|
|
|
* @return bool |
74
|
|
|
*/ |
75
|
4 |
|
private function userCheck(Company $company, Employee $employee) |
76
|
|
|
{ |
77
|
4 |
|
return $company->id === $employee->company_id; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.