Add role column migration and AdminSeeder

This commit is contained in:
ramzdhani11 2025-11-23 21:42:52 +07:00
parent df8ec5d175
commit c05f121ecd
2 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,28 @@
<?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::table('users', function (Blueprint $table) {
$table->string('role')->default('user');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('role');
});
}
};

View File

@ -0,0 +1,25 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
class AdminSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('users')->insert([
'name' => 'Admin',
'email' => 'admin@gmail.com',
'password' => Hash::make('admin123'),
'role' => 'admin',
'created_at' => now(),
'updated_at' => now(),
]);
}
}