KTV/database/seeders/CreateAdminUserSeeder.php

53 lines
1.6 KiB
PHP
Raw Normal View History

2025-04-25 09:33:28 +08:00
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\User;
use App\Jobs\ExportSqliteUserJob;
2025-04-25 09:33:28 +08:00
class CreateAdminUserSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$user = User::create([
'name' => 'Allen Yan(admin)',
'email' => 'admin@gmail.com',
'phone' => '0900000000',
'birthday' => now()->toDateString(),
2025-04-25 09:33:28 +08:00
'password' => bcrypt('aa1234')
]);
$user->assignRole('Admin');
2025-05-27 11:56:04 +08:00
$abilities = $user->getAllPermissions()->pluck('name')->toArray();
$token = $user->createToken('all', $abilities)->plainTextToken;
$user->api_plain_token = $token;
$user->save();
$user = User::create([
'name' => 'Allen Yan(machine)',
'email' => 'MachineKTV@gmail.com',
'phone' => '0900000001',
'birthday' => now()->toDateString(),
'password' => bcrypt('aa147258-')
]);
$user->assignRole('Machine');
2025-05-26 16:28:16 +08:00
$token = $user->createToken('pc-heartbeat')->plainTextToken;
$user->api_plain_token = $token;
$user->save();
2025-04-25 09:33:28 +08:00
$user = User::create([
'name' => 'Allen Yan(User)',
'email' => 'allen.yan@gmail.com',
'phone' => '0900000002',
'birthday' => now()->toDateString(),
2025-04-25 09:33:28 +08:00
'password' => bcrypt('aa1234')
]);
$user->assignRole('User');
(new ExportSqliteUserJob(false))->handle();
2025-04-25 09:33:28 +08:00
}
}