<?php
  
namespace Database\Seeders;
  
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\User;
use App\Jobs\ExportSqliteUserJob;
  
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(),
            'password' => bcrypt('aa1234')
        ]);
        $user->assignRole('Admin');
        $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');
        $token = $user->createToken('pc-heartbeat')->plainTextToken;
        $user->api_plain_token = $token;
        $user->save();
        
        $user = User::create([
            'name' => 'Allen Yan(User)', 
            'email' => 'allen.yan@gmail.com',
            'phone' => '0900000002',
            'birthday' => now()->toDateString(),
            'password' => bcrypt('aa1234')
        ]);
        $user->assignRole('User');

    }
}
