Raviya Technical
Published in

Raviya Technical

How to Disable Users from Login in Laravel

Step 1 — Add New Column ‘status’ in the users table

php artisan make:migration add_status_to_users_table
Schema::table('users', function (Blueprint $table) {
protected $fillable = [

Step 2 — Create a Middleware — CheckBanned

php artisan make:middleware CheckBanned
public function handle(Request $request, Closure $next)
if(auth()->check() && (auth()->user()->status == 0)){



return redirect()->route('login')->with('error', 'Your Account is suspended, please contact Admin.');


return $next($request);

Step 3 — Register the Middleware — app/Http/Kernel.php


Step 4 — Display The Error on the log-in page.

@if (session('error'))
<div class="alert alert-danger">
{{ session('error') }}



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store