- Forums
- laravel
- Laravel Add Admin Type To Users With Laravel Breeze Authentication Account
This Page Contains information about Laravel Add Admin Type To Users With Laravel Breeze Authentication Account By edw in category laravel with 0 Replies. [5292], Last Updated: Mon Jun 24, 2024
edw
Mon Feb 26, 2024
0 Comments
194 Visits
the purpose of this page is to show you how to add a column in the users table to allow to distinguish between a regular user and an admin user.
$ php artisan make:migration add_type_to_users_table
$ code database/migrations/*add_type_to_users_table.php
*add_type_to_users_table.php
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('type')->default('user'); //user or admin
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('type');
});
}
};
$ php artisan migrate