I found the following code showing how to modify the controller and the controller method in middleware:
class ChangeControllerMiddleware {
    public function handle($request, Closure $next) {
        $route = $request->route();
        $routeAction = array_merge($route->getAction(), [
            'uses'       => '\App\Http\Controllers\Foo@bar',
            'controller' => '\App\Http\Controllers\Foo@bar',
        ]);
        $route->setAction($routeAction);
        $route->controller = false;
        return $next($request);
    }
}
But this method doesn't work in 5.3. (I get this error: "Cannot access protected property Illuminate\Routing\Route::$controller".)
FYI: after $route->setAction($routeAction); my debugger shows that the route's 'uses' and 'controller' properties haven't updated.
Any ideas would be very helpful!
via Chebli Mohamed
 
Aucun commentaire:
Enregistrer un commentaire