|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace plunner\Http\Controllers\Companies\Groups; |
|
4
|
|
|
|
|
5
|
|
|
use plunner\Company; |
|
6
|
|
|
use plunner\Group; |
|
7
|
|
|
use plunner\Http\Controllers\Controller; |
|
8
|
|
|
use plunner\Http\Requests\Companies\GroupRequest; |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
class GroupsController extends Controller |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* ExampleController constructor. |
|
15
|
|
|
*/ |
|
16
|
22 |
|
public function __construct() |
|
17
|
|
|
{ |
|
18
|
22 |
|
config(['auth.model' => \plunner\Company::class]); |
|
19
|
22 |
|
config(['jwt.user' => \plunner\Company::class]); |
|
20
|
22 |
|
$this->middleware('jwt.authandrefresh:mode-cn'); |
|
21
|
22 |
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Display a listing of the resource. |
|
25
|
|
|
* |
|
26
|
|
|
* @return \Illuminate\Http\Response |
|
27
|
|
|
*/ |
|
28
|
2 |
|
public function index() |
|
29
|
|
|
{ |
|
30
|
|
|
// |
|
31
|
|
|
/** |
|
32
|
|
|
* @var $company Company |
|
33
|
|
|
*/ |
|
34
|
2 |
|
$company = \Auth::user(); |
|
35
|
2 |
|
return $company->groups; |
|
|
|
|
|
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Store a newly created resource in storage. |
|
40
|
|
|
* |
|
41
|
|
|
* @param GroupRequest $request |
|
42
|
|
|
* @return \Illuminate\Http\Response |
|
43
|
|
|
*/ |
|
44
|
6 |
|
public function store(GroupRequest $request) |
|
45
|
|
|
{ |
|
46
|
6 |
|
$company = \Auth::user(); |
|
47
|
6 |
|
$input = $request->all(); |
|
48
|
6 |
|
$group = $company->groups()->create($input); |
|
49
|
6 |
|
return $group; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Display the specified resource. |
|
54
|
|
|
* |
|
55
|
|
|
* @param int $id |
|
56
|
|
|
* @return \Illuminate\Http\Response |
|
57
|
|
|
*/ |
|
58
|
6 |
|
public function show($id) |
|
59
|
|
|
{ |
|
60
|
6 |
|
$group = Group::findOrFail($id); |
|
61
|
4 |
|
$this->authorize($group); |
|
62
|
2 |
|
return $group; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Update the specified resource in storage. |
|
67
|
|
|
* |
|
68
|
|
|
* @param GroupRequest $request |
|
69
|
|
|
* @param int $id |
|
70
|
|
|
* @return \Illuminate\Http\Response |
|
71
|
|
|
*/ |
|
72
|
2 |
|
public function update(GroupRequest $request, $id) |
|
73
|
|
|
{ |
|
74
|
2 |
|
$group = Group::findOrFail($id); |
|
75
|
2 |
|
$this->authorize($group); |
|
76
|
2 |
|
$input = $request->all(); |
|
77
|
2 |
|
$group->update($input); |
|
78
|
2 |
|
return $group; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Remove the specified resource from storage. |
|
83
|
|
|
* |
|
84
|
|
|
* @param int $id |
|
85
|
|
|
* @return \Illuminate\Http\Response |
|
86
|
|
|
*/ |
|
87
|
4 |
|
public function destroy($id) |
|
88
|
|
|
{ |
|
89
|
4 |
|
$group = Group::findOrFail($id); |
|
90
|
4 |
|
$this->authorize($group); |
|
91
|
2 |
|
$group->delete(); |
|
92
|
2 |
|
return $group; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.