<?php

namespace App\Modules\Frontend\Models;

use CodeIgniter\Model;

class BookingModel extends Model
{
    protected $DBGroup          = 'default';
    protected $table            = 'bookings';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'array';
    protected $useSoftDeletes   = false;
    protected $allowedFields    = [
        'tour_id', 'client_name', 'email', 'phone', 'travel_date',
        'pax', 'currency', 'total_amount', 'status', 'invoice_ref'
    ];
    protected $useTimestamps    = true;
    protected $createdField     = 'created_at';

    protected $validationRules = [
        'tour_id' => 'required|integer|is_not_unique[tours.id]',
        'client_name' => 'required|max_length[255]',
        'email' => 'required|valid_email',
        'phone' => 'required|max_length[20]',
        'travel_date' => 'required|valid_date',
        'pax' => 'required|integer|greater_than_equal_to[1]|less_than_equal_to[50]',
        'total_amount' => 'required|numeric|greater_than_equal_to[0]',
        'invoice_ref' => 'required|max_length[50]|is_unique[bookings.invoice_ref]',
    ];
}