<?php

namespace App\Models;

/**
 * See CreateBookingServiceItemsTable's doc comment — real service/extra
 * selections made during the New Booking wizard, snapshotted at
 * selection time, converted into real folio_line_items by
 * CheckInController the moment a folio actually opens.
 */
class BookingServiceItemModel extends TenantModel
{
    protected $table            = 'booking_service_items';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'object';
    protected $useTimestamps    = true;
    protected $createdField     = 'created_at';
    protected $updatedField     = '';

    protected $allowedFields = [
        'booking_id',
        'service_id',
        'service_name',
        'unit_price',
        'quantity',
    ];

    public function forBooking(int $bookingId): array
    {
        return $this->where('booking_id', $bookingId)->findAll();
    }
}
