<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;

use Illuminate\Database\Eloquent\Model;
use App\Traits\HotelScopeTrait;
use App\Traits\GeneratesUniqueNumbers;

class Receipt extends Model
{
    use HasFactory, HotelScopeTrait, GeneratesUniqueNumbers;

    protected function getNumberPrefix(): string
    {
        return 'RCT';
    }

    protected function getNumberColumn(): string
    {
        return 'receipt_number';
    }

    protected $fillable = [
        'hotel_id',
        'receipt_number',
        'invoice_id',
        'service_request_id',
        'guest_id',
        'amount_paid',
        'payment_date',
        'payment_method',
        'payment_status',
        'notes',
        'received_by'
    ];

    protected $casts = [
        'payment_date' => 'datetime',
        'amount_paid' => 'decimal:2',
    ];

    public function invoice()
    {
        return $this->belongsTo(Invoice::class);
    }

    public function serviceRequest()
    {
        return $this->belongsTo(ServiceRequest::class);
    }

    public function guest()
    {
        return $this->belongsTo(Guest::class);
    }

    public function receivedBy()
    {
        return $this->belongsTo(User::class, 'received_by');
    }
}