Juliatzin del Toro Juliatzin del Toro - 1 year ago 178
PHP Question

$request->request is null in laravel 5

I'm trying to define a Middleware FederationMiddleware:

public function handle($request, Closure $next)
dd($request->request); // prints null
if (Auth::check()) {
$userLogged = Auth::user();
if (!$userLogged->isSuperAdmin()) {
throw new UnauthorizedException;
return $next($request);

In Kernel.php

protected $routeMiddleware = array(
'federation' => Middleware\FederationMiddleware::class,

In my controller, I have:

public function __construct()

What I need basically, is to allow federation's owner to edit his own information, so, I need to parse the URL to know that if URL contains federations/{federationID} and federationID == user->federation()->id, grant access

Answer Source

Unless you need something more advanced, you could just parse it from the current url and make a check.

$path = $request->path();
if (preg_match('@^federation/(\d+)/edit$@', $path, $match)) {
    $federationId = $match[1];
    // compare with the user's federation id here

This will match sitename.xyz/federation/[somedigits]/edit and no other addresses.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download