Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
permissionMiddleware
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 handle
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace App\Http\Middleware\dashboard;
4
5use Closure;
6use Illuminate\Http\Request;
7
8class permissionMiddleware
9{
10    /**
11     * Handle an incoming request.
12     *
13     * @param  \Illuminate\Http\Request  $request
14     * @param  \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse)  $next
15     * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
16     */
17    public function handle(Request $request, Closure $next, $permission)
18    {
19        if(auth('user')->user()->has_permission($permission)){
20            return $next($request);
21        } else {
22            return abort(404);
23        }
24
25    }
26}