PHP code example of aldo / laravel-passwordless-login

1. Go to this page and download the library: Download aldo/laravel-passwordless-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/ */

    

aldo / laravel-passwordless-login example snippets




return [
    /*
    |
    | The namespace of your applications user model
    |
    */
    "model" => [
        "namespace" => "\App\Models\User",
    ],

    /*
    |
    | The route name and the url expiration in minutes
    |
    */
    "url" => [
        "route" => "login.verify",
        "expire" => 5,
    ],

    /*
    |--------------------------------------------------------------------------------
    | Only applicable if you are using the provided authentication implementation
    |--------------------------------------------------------------------------------
    |
    | Change flag to true if you want to use the provided implementation routes. 
    | This flag is necessary for not loading the routes if you don't want to use the default implementation.
    | This way you can avoid route collision.
    | 
    | The name of the home route to redirect to after login
    |
    */
    "routes" => [
        "flag" => false,
        
        "home" => "home",
    ],
];

use App\Models\User;
use Aldo\LaravelPasswordlessLogin\Facades\PasswordlessLogin;

function sendLoginLink()
{
    $user = User::first();
    
    $url = PasswordlessLogin::forUser($user)->generate();
    
    // You can also add remember me (by default it's false)
    $url = PasswordlessLogin::forUser($user)->remember()->generate();    
    
    // Send the url to the user
}

/*
|--------------------------------------------------------------------------------
| Only applicable if you are using the provided authentication implementation
|--------------------------------------------------------------------------------
|
| Change flag to true if you want to use the provided implementation routes. 
| This flag is necessary for not loading the routes if you don't want to use the default implementation.
| This way you can avoid route collision.
| 
| The name of the home route to redirect to after login
|
*/
"routes" => [
    "flag" => false, // change to true
    
    "home" => "home",
],
bash
  php artisan vendor:publish --tag=passwordless-config
bash
  php artisan vendor:publish --tag=passwordless-migrations
bash
  php artisan migrate
bash
  php artisan vendor:publish --tag=passwordless-views