How to pass argument to middleware " i pass parameter 'admissions' in $type"

Posted 5 months ago by tanveerkhanwd
//My Middleware :
public function handle($request, Closure $next, $type)
    {
        if (Auth::User()->role_id!=1) {
            $currentUser = Auth::user()->role_id;
            $permissionData = Privilege::select('role_id','permission')
            ->where('role_id','=',$currentUser)->first();
            $permissionData = json_decode($permissionData['permission'],true);
            if ($permissionData->$type) {
                return $next($request);   
               }
            else
            {
                return redirect()->back();   
            }   
        }
        else
        {
            return $next($request);
        }
    }


// My Controller:

public function __construct()
    {
        $this->middleware('permission:admissions');
    }

Please sign in or create an account to participate in this conversation.