mirror of
https://github.com/Aviortheking/CA_LARAVEL.git
synced 2025-06-15 19:09:19 +00:00
fix migration && add seeder && add is_admin
This commit is contained in:
47
app/Http/Middleware/IsAdmin.php
Normal file
47
app/Http/Middleware/IsAdmin.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
|
||||
|
||||
use Closure;
|
||||
|
||||
|
||||
|
||||
class IsAdmin
|
||||
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
* Handle an incoming request.
|
||||
|
||||
*
|
||||
|
||||
* @param \Illuminate\Http\Request $request
|
||||
|
||||
* @param \Closure $next
|
||||
|
||||
* @return mixed
|
||||
|
||||
*/
|
||||
|
||||
public function handle($request, Closure $next)
|
||||
|
||||
{
|
||||
|
||||
if(auth()->user()->is_admin == 1){
|
||||
|
||||
return $next($request);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return redirect(‘home’)->with(‘error’,"You don't have admin access.");
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user