<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class PermissionCheck
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
$route = $request->route()->uri();
$methodArray = $request->route()->methods();
$method = $methodArray[0];
/* dd($method); */
$allow_method = ["GET","POST","PUT","DELETE"];
if(in_array($method,$allow_method)){
$request->merge(array("addedInMiddleware" => true));
/* /** */
/* * This variable is available globally on all your views, and sub-views */
/* */
view()->share('my_global_variable', "I am global for view");
return $next($request);
}
else{
return new Response(view('404'));
}
/* return $next($request); */
}
}