Skip to content
IRFA edited this page Jul 23, 2020 · 1 revision

Usage


Unlock Account

Unlock account with Console artisan

php artisan lockout:unlock username

Unlock account programmatically

use Lockout;
use Request;

class UserManage {
	public function account_unlock(Request $request){
        Lockout::unlock($request->email);
        return redirect()->back();
    }
}

Lock Account manually

Lock account with Console artisan

php artisan lockout:lock username

Lock Account programmatically

use Lockout;
use Request;

class UserManage {
	public function account_unlock(Request $request){
        Lockout::lock($request->email);
        return redirect()->back();
    }
}

Check Locked Account

use Lockout;
use Request;

class UserManage {
	public function account_unlock(Request $request){
        $check = Lockout::isLocked($request->email);//return boolean
        if($check){
        	return "Locked";
        } else{
        	return "Unlocked";
        }
        
    }
}

Check Login Attemps

View login attemps with Console artisan

php artisan lockout:check username

Check Login attemps programmatically

use Lockout;
use Request;

class UserManage {
	public function account_unlock(Request $request){
        $lockout = Lockout::check($request->email);
        foreach($lockout as $data){
            echo $data->username."\n";
            echo $data->attemps."\n";
            echo $data->ip."\n";
            echo $data->last_attemps."\n";
        }
    }
}

Clear all Login Attemps

php artisan lockout:clear

Clear all programmatically

use Lockout;
use Request;

class UserManage {
	public function account_unlock(Request $request){
       Lockout::clearAll();
    }
}

Other Commands

php artisan lockout:info //Show more info this package
php artisan lockout:diagnose //diagnose and testing lockout account

Change Messages

You can change message in `resources/lang/{language}/lockoutMessage.php`

Show Message

Lockout::message()

How to Uninstall

  1. Run this command ( if your application runs in production it is recomended to run php artisan down before running this command)
composer remove irfa/lockout
  1. Remove service provider for this package in config/app.php
'providers' => [
      	 ....
         Irfa\Lockout\LockoutAccountServiceProvider::class, 
     ];
  1. Remove aliases for this package in config/app.php
'aliases' => [
         ....
    	'Lockout' => Irfa\Lockout\Facades\Lockout::class,
],
  1. Remove file config/irfa/lockout.php ( if your application runs in production it is recomended to run php artisan up after running this command)