<?php

namespace Database\Factories;

use App\Models\SecurityManagement\Role;
use App\Models\UserManagement\Admin;
use App\Models\UserManagement\User;
use App\Models\UserManagement\UserType;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

class AdminFactory extends Factory{

    protected $model = Admin::class;

    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition(){
        return [
            'first_name' => $this->faker->firstName,
            'last_name' => $this->faker->lastName,
            'username' => $this->faker->unique()->userName,
            'email' => $this->faker->unique()->safeEmail,
            'email_verified_at' => now(),
            'phone' => $this->faker->unique()->phoneNumber,
            'password' => bcrypt('123456'),
            'active' => 1,
            'remember_token' => Str::random(10),
        ];
    }

    public function configure(){
        return $this->afterCreating(function (User $user) {

        });
    }

    public function unverified(): \Illuminate\Database\Eloquent\Factories\Factory{
        return $this->state(function (array $attributes) {
            return [
                'email_verified_at' => now(),
            ];
        });
    }

    public function customer(): \Illuminate\Database\Eloquent\Factories\Factory{
        return $this->state(function (array $attributes) {
            return [
                UserType::FK_ID => UserType::CUSTOMER,
            ];
        });
    }

    public function staff(): \Illuminate\Database\Eloquent\Factories\Factory{
        return $this->state(function (array $attributes) {
            return [
                UserType::FK_ID => UserType::ADMIN,
            ];
        });
    }


}
