<?php
namespace Database\Factories;
use App\Models\UserProfile;
use App\Models\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class UserProfileFactory extends Factory
{
    /**
     * The name of the factory's corresponding model.
     *
     * @var string
     */
    
    protected $model = UserProfile::class;
    protected $user_id = 1;
    protected $isOnce = true;
    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        if($this->isOnce){
            $this->isOnce = false;
            $lastId = DB::table('users')->latest('id')->first();
            if($lastId){
                $this->user_id = $lastId->id + 1;
            }
            
        }
        return [
            'user_id' => $this->user_id++,
            'first_name' => $this->faker->name,
            'middle_name' => $this->faker->name,
            'last_name' => $this->faker->name,
            'gender' => "male",
            'birthday' =>  $this->faker->date($format = 'y-m-d', $max = '2012',$min = '1990'),
            'mobile_number' => $this->faker->phoneNumber,
            'brgy' => "san vicente",
            'city' =>"binan",
            'state' =>"laguna",
            'country'=> "philippines",
            'zip_code' => 4024,
            "current_address" =>"blk 22b"
        ];
    }
}