<?php

namespace App\Models;

class DiningTableModel extends TenantModel
{
    protected $table            = 'dining_tables';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'object';
    protected $useTimestamps    = true;

    protected $allowedFields = ['table_number', 'dining_area_id', 'seating_capacity'];

    protected $validationRules = [
        'table_number'     => 'required|max_length[20]|tenant_unique[dining_tables.table_number,id,{id}]',
        'dining_area_id'   => 'required|integer',
        'seating_capacity' => 'required|integer|greater_than[0]',
    ];

    public function withArea()
    {
        return $this->select('dining_tables.*, dining_areas.name as area_name')
            ->join('dining_areas', 'dining_areas.id = dining_tables.dining_area_id');
    }
}
