1 | <?php |
||
24 | class UsersController extends AuthorizedController |
||
25 | { |
||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | protected $resourceAbilityMap = [ |
||
30 | 'activate' => 'activate', |
||
31 | 'deactivate' => 'deactivate', |
||
32 | ]; |
||
33 | |||
34 | /** |
||
35 | * The user repository instance. |
||
36 | * |
||
37 | * @var \Rinvex\Fort\Contracts\UserRepositoryContract |
||
38 | */ |
||
39 | protected $userRepository; |
||
40 | |||
41 | /** |
||
42 | * Create a new users controller instance. |
||
43 | * |
||
44 | * @return void |
||
|
|||
45 | */ |
||
46 | public function __construct(UserRepositoryContract $userRepository) |
||
54 | |||
55 | /** |
||
56 | * Display a listing of the resource. |
||
57 | * |
||
58 | * @return \Illuminate\Http\Response |
||
59 | */ |
||
60 | public function index() |
||
66 | |||
67 | /** |
||
68 | * Display the specified resource. |
||
69 | * |
||
70 | * @param int $id |
||
71 | * |
||
72 | * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse |
||
73 | */ |
||
74 | public function show($id) |
||
75 | { |
||
76 | if (! $user = $this->userRepository->find($id)) { |
||
77 | return intend([ |
||
78 | 'intended' => route('rinvex.fort.backend.users.index'), |
||
79 | 'withErrors' => ['rinvex.fort.user.not_found' => trans('rinvex.fort::backend/messages.user.not_found', ['user' => $id])], |
||
80 | ]); |
||
81 | } |
||
82 | |||
83 | $actions = ['view', 'create', 'edit', 'delete', 'import', 'export']; |
||
84 | $resources = app('rinvex.fort.ability')->findAll()->groupBy('resource'); |
||
85 | $columns = ['resource', 'view', 'create', 'edit', 'delete', 'import', 'export', 'other']; |
||
86 | $userCountry = Loader::country($user->country); |
||
87 | $country = ! empty($userCountry) ? $userCountry->getName().' '.$userCountry->getEmoji() : null; |
||
88 | $phone = ! empty($userCountry) ? $userCountry->getCallingCode().$user->phone : null; |
||
89 | |||
90 | return view('rinvex.fort::backend.users.show', compact('user', 'resources', 'actions', 'columns', 'country', 'phone')); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Bulk control the given resources. |
||
95 | * |
||
96 | * @return \Illuminate\Http\Response |
||
97 | */ |
||
98 | public function bulk() |
||
102 | |||
103 | /** |
||
104 | * Show the form for creating a new resource. |
||
105 | * |
||
106 | * @return \Illuminate\Http\Response |
||
107 | */ |
||
108 | public function create() |
||
112 | |||
113 | /** |
||
114 | * Show the form for copying the given resource. |
||
115 | * |
||
116 | * @param int $id |
||
117 | * |
||
118 | * @return \Illuminate\Http\Response |
||
119 | */ |
||
120 | public function copy($id) |
||
124 | |||
125 | /** |
||
126 | * Show the form for editing the given resource. |
||
127 | * |
||
128 | * @param int $id |
||
129 | * |
||
130 | * @return \Illuminate\Http\Response |
||
131 | */ |
||
132 | public function edit($id) |
||
136 | |||
137 | /** |
||
138 | * Show the form for create/edit/copy of the given resource. |
||
139 | * |
||
140 | * @param string $mode |
||
141 | * @param string $action |
||
142 | * @param int|null $id |
||
143 | * |
||
144 | * @return \Illuminate\Http\Response |
||
145 | */ |
||
146 | protected function form($mode, $action, $id = null) |
||
160 | |||
161 | /** |
||
162 | * Store a newly created resource in storage. |
||
163 | * |
||
164 | * @param \Illuminate\Http\Request $request |
||
165 | * |
||
166 | * @return \Illuminate\Http\Response |
||
167 | */ |
||
168 | public function store(Request $request) |
||
172 | |||
173 | /** |
||
174 | * Update the given resource in storage. |
||
175 | * |
||
176 | * @param \Illuminate\Http\Request $request |
||
177 | * @param int $id |
||
178 | * |
||
179 | * @return \Illuminate\Http\Response |
||
180 | */ |
||
181 | public function update(Request $request, $id) |
||
185 | |||
186 | /** |
||
187 | * Delete the given resource from storage. |
||
188 | * |
||
189 | * @param int $id |
||
190 | * |
||
191 | * @return \Illuminate\Http\Response |
||
192 | */ |
||
193 | public function delete($id) |
||
197 | |||
198 | /** |
||
199 | * Import the given resources into storage. |
||
200 | * |
||
201 | * @return \Illuminate\Http\Response |
||
202 | */ |
||
203 | public function import() |
||
207 | |||
208 | /** |
||
209 | * Export the given resources from storage. |
||
210 | * |
||
211 | * @return \Illuminate\Http\Response |
||
212 | */ |
||
213 | public function export() |
||
217 | } |
||
218 |
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.