<?php
namespace EasyRestaurantManager\Http\Requests;

class StoreReservationRequest extends RequestGuard {
    
    /**
     * Define validation rules
     */
    public function rules() {
        return [
            'customer_name' => 'required|string',
            'email' => 'required|email', 
            'phone' => 'required|string',
            'reservation_time' => 'required|string', 
            'num_guests' => 'required|integer', 
            'reservation_date' => 'required|date',
            'table_id' => 'required|integer',
            'status' => 'required|string',
            'branch_id' => 'required|integer',
            'customer_id' => 'required|integer',
        ];
    }

    /**
     * Define custom validation messages
     */
    public function messages() {
        return [
            'customer_name.required' => esc_html__('Name is required.', 'easy-restaurant-manager'),
            'phone.required' => "Phone is required.",
            'email.required' => "Email value is required.",
            'table_id.required' => "Table id is required.",
            'reservation_date.required' => "Reservation Date is required.",
            'reservation_time.required' => "Reservation Time value is required.",
            'num_guests.required' => "Person is required.",
            'status.required' => "Reservation status is required.",
            'branch_id.required' => "Branch id is required.",
            'customer_id.required' => "Customer id is required.",
        ];
    }

    /**
     * Define sanitization rules
     */
    public function sanitize() {
        return [
            'table_number ' => 'sanitize_text_field',
            'capacity' => 'sanitize_text_field',
            'status' => 'sanitize_text_field',
            'branch_id' => 'sanitize_text_field',
            'customer_id' => 'sanitize_text_field',
            'customer_name' => 'sanitize_text_field',
            'phone' => 'sanitize_text_field', // If storing as string, otherwise use intval()
            'email' => 'sanitize_email',
            'table_id' => 0,// Ensures it's an integer
            'reservation_date' => 'sanitize_text_field',
            'reservation_time' => 'sanitize_text_field',
            'num_guests' => 'absint', // Ensures it's an integer
            'status' => 'sanitize_text_field',
            'notes' => 'sanitize_textarea_field',
        ];
    }
}
