Skip to content

Instantly share code, notes, and snippets.

@rawaludin
Last active September 28, 2015 09:32
Show Gist options
  • Save rawaludin/7cf4cf245ddfbc30a1af to your computer and use it in GitHub Desktop.
Save rawaludin/7cf4cf245ddfbc30a1af to your computer and use it in GitHub Desktop.
Lokasi: /app/Http/Middleware/UserSuspension.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
class UserSuspension
{
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);
if ($this->auth->user()->banned == 0) {
return $response;
}
$this->auth->logout();
return redirect()->route('login');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment