<?php

namespace App\Http\Requests\Users;

use App\Http\Requests\ApiFormRequest;
use Illuminate\Validation\Rule;

class UserStoreRequest extends ApiFormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function validationData(): array
    {
        return request()->all();
    }

    public function rules(): array
    {
        return [
            'firstname' => ['required', 'string', 'max:255'],
            'lastname' => ['required', 'string', 'max:255'],
            'gender' => ['nullable', 'string', Rule::in(['Male', 'Female', 'male', 'female', 'MALE', 'FEMALE'])],
            'cellphone' => ['required', 'string', 'max:25'],
            'email' => ['required', 'email', 'max:255', 'unique:users,email'],
            'address_street' => ['required', 'string', 'max:255'],
            'apt' => ['nullable', 'string', 'max:25'],
            'city' => ['required', 'string', 'max:255'],
            'state' => ['required', 'string', 'max:25'],
            'zip' => ['required', 'string', 'max:25'],
            'accept_school_policy' => ['required', 'boolean'],
            'role_id' => ['required', 'integer', 'exists:roles,id'],
            'password' => ['required', 'string', 'min:6'],
            'semester' => ['required', 'string', 'max:255'],
            'school_year' => ['nullable', 'string', 'max:9'],
            'school_id' => ['nullable', 'integer'],
            'user_type' => ['nullable', 'string', Rule::in(['primary', 'secondary', 'tertiary'])],
            'rfid_tag' => ['nullable', 'string', 'max:100'],
            'status' => ['nullable', 'string', Rule::in(['Active', 'Inactive'])],
            'is_verified' => ['nullable', 'boolean'],
            'is_suspended' => ['nullable', 'boolean'],
            'failed_attempts' => ['nullable', 'integer'],
            'last_failed_at' => ['nullable', 'date'],
            'token' => ['nullable', 'string', 'max:255'],
            'account_id' => ['nullable', 'string', 'max:255'],
        ];
    }
}
