File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -164,8 +164,14 @@ public function index()
164
164
*
165
165
* @return mixed
166
166
*/
167
- public function show ($ id )
167
+ public function show ()
168
168
{
169
+ // We need to do this in order to support multiple parameter resource routes. For example,
170
+ // if we map route /user/{user}/comments/{comment} to a controller, Laravel will pass `user`
171
+ // as first argument and `comment` as last argument. So, id object that we want to fetch
172
+ // is the last argument.
173
+ $ id = last (func_get_args ());
174
+
169
175
$ this ->validate ();
170
176
171
177
$ results = $ this ->parseRequest ()
@@ -210,10 +216,12 @@ public function store()
210
216
return ApiResponse::make ("Resource created successfully " , [ "id " => $ object ->id ], $ meta );
211
217
}
212
218
213
- public function update ($ id )
219
+ public function update ()
214
220
{
215
221
\DB ::beginTransaction ();
216
222
223
+ $ id = last (func_get_args ());
224
+
217
225
$ this ->validate ();
218
226
219
227
// Get object for update
@@ -246,10 +254,12 @@ public function update($id)
246
254
return ApiResponse::make ("Resource updated successfully " , [ "id " => $ object ->id ], $ meta );
247
255
}
248
256
249
- public function destroy ($ id )
257
+ public function destroy ()
250
258
{
251
259
\DB ::beginTransaction ();
252
260
261
+ $ id = last (func_get_args ());
262
+
253
263
$ this ->validate ();
254
264
255
265
// Get object for update
You can’t perform that action at this time.
0 commit comments