PHPackages                             nextmigrant/magic-link-login - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. nextmigrant/magic-link-login

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

nextmigrant/magic-link-login
============================

A scaffolding package for Magic Link Authentication in Laravel Filament applications.

1.0.2(4mo ago)04MITPHP

Since Jan 8Pushed 4mo agoCompare

[ Source](https://github.com/NextMigrant/magic-link-login)[ Packagist](https://packagist.org/packages/nextmigrant/magic-link-login)[ RSS](/packages/nextmigrant-magic-link-login/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (5)Used By (0)

Magic Link Login Scaffolding Package
====================================

[](#magic-link-login-scaffolding-package)

A scaffolding package for Magic Link Authentication in Laravel and Filament applications. This package installs the necessary files into your Laravel application and then removes itself, leaving you with full control over the code.

Installation
------------

[](#installation)

1. **Require the package** as a development dependency:

    ```
    composer require --dev nextmigrant/magic-link-login
    ```
2. **Run the install command**:

    ```
    php artisan magic-link:install
    ```

    This command will interactively guide you through the process:

    - **Copy Files**: Scaffolds Models, Controllers, Livewire components, Views, and Mailables into your application.
    - **Configure Routes**: Automatically creates or updates `routes/admin/admin.php`.
    - **Update User Model**: Automatically injects the `HasMagicLogin` trait into `app/Models/User.php`.
    - **Cleanup**: Offers to remove the package dependency (`composer remove`) to keep your project dependencies clean.
3. **Run migrations**:

    ```
    php artisan migrate
    ```

Post-Installation
-----------------

[](#post-installation)

1. **Disable Default Filament Login**: In your `app/Providers/Filament/AdminPanelProvider.php`, you must remove or comment out the `->login()` method to disable the default Filament login page. This package provides its own authentication flow.

    ```
    public function panel(Panel $panel): Panel
    {
        return $panel
            // ...
            // ->login() // queue(new MagicLoginLink($temporaryLoginLink));

    // Synchronous (Immediate)
    Mail::to($user)->send(new MagicLoginLink($temporaryLoginLink));
    ```

Usage without Filament
----------------------

[](#usage-without-filament)

While this package is designed for Filament, it can be used with any Laravel application.

If you are not using Filament, you simply need to update the **redirect destination** after a successful login.

1. Open `app/Http/Controllers/Admin/AuthController.php`.
2. Locate the `login` method.
3. Change the redirect to your desired dashboard route:

    ```
    return redirect()->to(
        // Filament::getPanel('admin')->getUrl() //
