generated from liutk/owl-admin-base
52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\AdminRole;
|
|
use App\Models\AdminUser;
|
|
use App\Models\Employee;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class AdminSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
foreach ([
|
|
'admin_roles',
|
|
'admin_users',
|
|
'admin_role_users',
|
|
'employees',
|
|
] as $table) {
|
|
DB::table($table)->truncate();
|
|
}
|
|
|
|
$roleAdministrator = AdminRole::create([
|
|
'name' => 'Administrator',
|
|
'slug' => 'administrator',
|
|
]);
|
|
$roleAdmin = AdminRole::create([
|
|
'name' => '管理员',
|
|
'slug' => 'admin',
|
|
]);
|
|
|
|
$admin = AdminUser::create([
|
|
'username' => 'admin',
|
|
'password' => bcrypt('admin'),
|
|
]);
|
|
|
|
$admin->employee()->create([
|
|
'name' => 'admin',
|
|
'phone' => '12345678900',
|
|
'join_at' => now(),
|
|
]);
|
|
|
|
$admin->roles()->saveMany([$roleAdministrator, $roleAdmin]);
|
|
}
|
|
}
|