<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'name' => 'required|string|max:100',
            'email' => 'required|email|unique:users,email', // Changed to 'users' table
            'no_telp' => 'required|string|max:20', // Assuming 'no_telp' is a string field
            'password' => 'required|string|min:4', // Adjusted minimum password length
            'role_id' => 'required|exists:roles,id', // Ensures role_id exists in the 'roles' table
        ];
    }
}
