PHP code example of arzcode / filament-magic-login
1. Go to this page and download the library: Download arzcode/filament-magic-login 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/ */
arzcode / filament-magic-login example snippets
use Arzcode\FilamentMagicLogin\MagicLoginPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->id('admin')
->login()
->plugin(MagicLoginPlugin::make());
}
MagicLoginPlugin::make()->sendToReachablePanel() // any panel with the plugin
MagicLoginPlugin::make()->sendToReachablePanel(['app', 'staff']) // these, most preferred first
use Arzcode\FilamentMagicLogin\Actions\SendMagicLinkAction;
protected function getHeaderActions(): array
{
return [
SendMagicLinkAction::make(),
];
}
MagicLoginPlugin::make()->adminIcon('heroicon-o-key') // action and modal, every placement
MagicLoginPlugin::make()->icon('heroicon-o-key') // the login page's action too
SendMagicLinkAction::make()->icon('heroicon-o-key') // this placement only
// app/Policies/UserPolicy.php
public function sendMagicLink(User $administrator, User $target): bool
{
return $administrator->hasRole('super-admin');
}
use Arzcode\FilamentMagicLogin\Concerns\HasMagicLinkAction;
use Filament\Auth\Pages\Login;
class MyLogin extends Login
{
use HasMagicLinkAction;
}
use Arzcode\FilamentMagicLogin\Contracts\MagicLinkNotification;
use Illuminate\Notifications\Notification;
class MyMagicLinkNotification extends Notification implements MagicLinkNotification
{
public function __construct(
public string $url,
public int $expiresAfterMinutes,
public string $panelId,
) {}
// ...
}
use Illuminate\Support\Facades\Schedule;
use Arzcode\FilamentMagicLogin\Models\MagicLoginToken;
Schedule::command('model:prune', [
'--model' => [MagicLoginToken::class],
])->daily();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.