Laravel 11 | FilamentPHP 3.2 How to Implement Custom Guards for Authentication Using the Admin Model
In this tutorial, we will go through the process of building an Admin model in Laravel 11 with FilamentPHP 3.2. In this guide, you will learn to set up dedicated authentication for your admin panel.
Steps:1- Create Admin Model
First you need to create the Admin model and also the migration file. Open terminal and run this command
php artisan make:model Admin -m
This command will generate the model Admin and also a migration file that we run to create the database table.
Step 2: Modify the Migration File
Next, you’ll need to edit the migration file to define the structure of the admins
table. The migration file can be found in the database/migrations
directory. You may rename it for clarity, for example: 2023_11_03_000000_create_admins_table.php
.
Here’s how your migration file should look:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('admins', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique()…