I'm working with Laravel 5.1.
Let's say that I have a route group defined like this:
Route::group(array('prefix' => 'item/{itemId?}', 'middleware' => ['itemStrip']), function(){
And within the Middleware itemStrip, I want to work with the item passed, then remove it from the URI before moving onto a resource within the group. The Resource would be defined like this, for example:
Route::resource('itemA.itemB',
'ItemController',
['only'=>['index']]);
So, this resource has one variable that it needs to access, which is held between itemA and itemB.
I find that, even if I use
$request->route()->forgetParameter('itemId');
within the itemStrip middleware, the parameter still ends up making it to the actual resource. Which is to say, when we finally hit:
public function index($itemAId)
within the resource controller, it is grabbing the parameter itemId as opposed to the parameter between itemA and itemB. Why is this, after I stripped the Parameter from the route in the Middleware? Is there anyway to fully remove itemId, in order to keep it from hitting the resource?
A little more information, I'm finishing the Middleware with this:
return $next($request);
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire