Admin.php 415 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. class Admin
  5. {
  6. /**
  7. * Handle an incoming request.
  8. *
  9. * @param \Illuminate\Http\Request $request
  10. * @param \Closure $next
  11. * @return mixed
  12. */
  13. public function handle($request, Closure $next)
  14. {
  15. if ($request->user()->admin)
  16. {
  17. return $next($request);
  18. }
  19. return new RedirectResponse(url('post/liste'));
  20. }
  21. }