To use authentication for custom guard in your package using Laravel 6, you can follow these steps:

  1. Define a custom guard in your package's service provider using the Auth::extend() method. For example, you can add the following code to the register() method in your service provider:
Auth::extend('custom-guard', function ($app, $name, $config) { // Define the logic for your custom guard here return new CustomGuard($app[''], $app['request']); });
  1. Create a class for your custom guard that implements the Guard interface. For example:
use Illuminate\Contracts\Auth\Guard; class CustomGuard implements Guard { // Define the methods required by the Guard interface here }
  1. Define the authentication logic for your custom guard. This can include checking credentials, retrieving users from a database, and storing user information in the session.

  2. Use your custom guard in your package's routes or controllers by specifying the guard name in the auth middleware. For example:

Route::middleware('auth:custom-guard')->get('/mypage', function () { return view('mypage'); });

With these steps, you should be able to use authentication for your custom guard in your package using Laravel 6.

Have questions or queries?
Get in Touch