Skip to content

Instantly share code, notes, and snippets.

@Aslam97
Created October 11, 2020 14:19
Show Gist options
  • Save Aslam97/beefa10b69e27809d006fbad01a69b41 to your computer and use it in GitHub Desktop.
Save Aslam97/beefa10b69e27809d006fbad01a69b41 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Route;
class CurrentRouteMiddleware
{
/**
* route
*
* @var mixed
*/
private $route;
/**
* __construct
*
* @return void
*/
public function __construct()
{
$this->route = Route::currentRouteName();
}
/**
* handle
*
* @param mixed $request
* @param mixed $next
* @return void
*/
public function handle($request, Closure $next)
{
view()->share('route', $this->route);
return $next($request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment