Awar Pulldozer
Awar Pulldozer

Reputation: 1101

How to get the URL in the middleware in Laravel 5.5?

i have project on laravel 5.5 im using middleware and this is the code

<?php
namespace App\Http\Middleware;
use Closure;
class roleMiddleware
{
 public function handle($request, Closure $next)
{
    // if code to check where the url is 
    // code here
    //else
    //code here
    //else
    //code
    //return $next($request);
}
}

so i need code to check where the request come from and if it == something do this if it == something else do that

Upvotes: 0

Views: 718

Answers (1)

Mauricio Rodrigues
Mauricio Rodrigues

Reputation: 807

You can use inside of your middleware:

$request->url(); // without query string

With query string you can use:

$request->fullUrl();

For more Request methods, see Illuminate\Http\Request.php class.

Upvotes: 1

Related Questions