PHP code example of haikallfiqih / laravel-magic-auth
1. Go to this page and download the library: Download haikallfiqih/laravel-magic-auth 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/ */
haikallfiqih / laravel-magic-auth example snippets
use LaravelLinkAuth\MagicAuth\Facades\MagicAuth;
// Send via email (default)
MagicAuth::sendMagicLink('[email protected]');
// Send via WhatsApp
MagicAuth::sendMagicLink('+1234567890', 'web', [], ['whatsapp']);
// Send via SMS
MagicAuth::sendMagicLink('+1234567890', 'web', [], ['sms']);
// With custom attributes for new users
MagicAuth::sendMagicLink('[email protected]', 'web', [
'name' => 'John Doe',
'company_id' => 1
]);
use LaravelLinkAuth\MagicAuth\Facades\Events;
use LaravelLinkAuth\MagicAuth\Events\MagicAuthEvents;
// Before generating a magic link
Events::listen(MagicAuthEvents::GENERATING, function ($notifiable, $guard, $attributes) {
// Validate or modify attributes
});
// After sending a magic link
Events::listen(MagicAuthEvents::SENT, function ($notifiable, $guard, $linkId) {
// Log or track magic link usage
});
// When verification succeeds
Events::listen(MagicAuthEvents::VERIFICATION_COMPLETED, function ($user, $guard) {
// Handle successful login
});