PHP code example of looplinguist / secure-password-policy

1. Go to this page and download the library: Download looplinguist/secure-password-policy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

looplinguist / secure-password-policy example snippets



use Illuminate\Database\Eloquent\Relations\HasMany;
use LoopLinguist\SecurePasswordPolicy\Models\PasswordHistory;

class User extends Authenticatable
{
    //  ... 

    public function passwordHistories(): HasMany
    {
        return $this->hasMany(PasswordHistory::class);
    }
}


use LoopLinguist\SecurePasswordPolicy\Http\HasPasswordHistory;

 if ((new HasPasswordHistory($request->input('password')))->hasHistory()) {
            return response()->json([
                'message' => 'Password found.'
            ], 409);
        }
bash
php artisan vendor:publish --tag=secure-password-policy-config    
bash
php artisan vendor:publish --tag=secure-password-policy-migrations    
bash
php artisan migrate