1 | <?php |
||
18 | class EmployeesController extends Controller |
||
19 | { |
||
20 | 24 | public function __construct() |
|
26 | |||
27 | |||
28 | /** |
||
29 | * Display a listing of the resource. |
||
30 | * |
||
31 | * @param int $groupId |
||
32 | * @return \Illuminate\Http\Response |
||
33 | */ |
||
34 | 3 | public function index($groupId) |
|
35 | { |
||
36 | // |
||
37 | 3 | $group = Group::findOrFail($groupId); |
|
38 | 3 | $this->authorize($group); |
|
39 | 3 | return $group->employees; |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * Store a newly created resource in storage. |
||
44 | * |
||
45 | * @param EmployeeRequest $request |
||
46 | * @param int $groupId |
||
47 | * @return \Illuminate\Http\Response |
||
48 | */ |
||
49 | 6 | public function store(EmployeeRequest $request, $groupId) |
|
50 | { |
||
51 | // |
||
52 | 6 | $group = Group::findOrFail($groupId); |
|
53 | 6 | $this->authorize($group); |
|
54 | 3 | $id = $request->all()['id']; |
|
55 | 3 | $group->employees()->attach($id); |
|
56 | 3 | return $group->employees; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * Remove the specified resource from storage. |
||
61 | * |
||
62 | * @param int $groupId |
||
63 | * @param int $employeeId |
||
64 | * @return \Illuminate\Http\Response |
||
65 | */ |
||
66 | 12 | public function destroy($groupId, $employeeId) |
|
77 | } |
||
78 |