32 lines
768 B
PHP
32 lines
768 B
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
{
|
|
public function run(): void
|
|
{
|
|
// 1. Dọn dẹp an toàn
|
|
Schema::disableForeignKeyConstraints();
|
|
User::query()->delete();
|
|
Schema::enableForeignKeyConstraints();
|
|
|
|
// 2. Tạo tài khoản quản trị Admin
|
|
User::create([
|
|
'name' => 'chanphuong',
|
|
'email' => 'admin@phuongtc.com',
|
|
'password' => Hash::make('1Qazxsw2@!321'),
|
|
]);
|
|
|
|
// 3. Gọi bộ nạp dữ liệu Test chuyên sâu
|
|
$this->call([
|
|
TestDataSeeder::class,
|
|
]);
|
|
}
|
|
}
|