PHP code example of nagibmahfuj / laravel-security-policies
1. Go to this page and download the library: Download nagibmahfuj/laravel-security-policies 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/ */
nagibmahfuj / laravel-security-policies example snippets
use NagibMahfuj\LaravelSecurityPolicies\Rules\StrongPassword;
use NagibMahfuj\LaravelSecurityPolicies\Rules\NotInRecentPasswords;
$request->validate([
'password' => ['
use NagibMahfuj\LaravelSecurityPolicies\Rules\StrongPasswordRule;
use NagibMahfuj\LaravelSecurityPolicies\Rules\NotInRecentPasswordsRule;
$request->validate([
'password' => ['
'session' => [
'last_activity_store' => 'database', // or 'session' for the default behavior
],
'user_columns' => [
'last_activity_at' => 'last_active_at', // customize column name if needed
],
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Support\Facades\Hash;
// Update password
$user->update([
'password' => Hash::make($request->password),
]);
// Trigger event
event(new PasswordReset($user));