PHP code example of phpsa / filament-authentication
1. Go to this page and download the library: Download phpsa/filament-authentication 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/ */
phpsa / filament-authentication example snippets
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
php artisan migrate
public function panel(Panel $panel): Panel
{
return $panel
...
->plugins([
\Phpsa\FilamentAuthentication\FilamentAuthentication::make(),
])
...
/**
* @return bool
*/
public function canImpersonate()
{
// For example
return $this->is_admin == 1;
}
/**
* @return bool
*/
public function canBeImpersonated()
{
// For example
return $this->can_be_impersonated == 1;
}
Router::get('/my-credit-card', function() {
echo "Can't be accessed by an impersonator";
})->middleware('impersonate.protect');
use CanRenewPassword {
CanRenewPassword::needsRenewal as traitNeedsRenewal;
}
public function needsRenewal(): bool
{
if ($this->password === null && SocialiteUser::where('user_id', $this->id)->exists()) {
return false;
}
return $this->traitNeedsRenewal();
}
protected $policies = [
Role::class => RolePolicy::class,
Permission::class => PermissionPolicy::class,
CustomPage::class => CustomPagePolicy::class,
SettingsPage::class => SettingsPagePolicy::class
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
];
bash
php artisan filament-authentication:install