<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Table extends Model
{
    protected $fillable = ['outlet_id', 'number', 'capacity', 'status', 'merged_to_id'];

    public function outlet(): BelongsTo
    {
        return $this->belongsTo(Outlet::class);
    }

    public function mergedTo(): BelongsTo
    {
        return $this->belongsTo(Table::class, 'merged_to_id');
    }

    public function mergedFrom(): HasMany
    {
        return $this->hasMany(Table::class, 'merged_to_id');
    }

    public function transactions(): HasMany
    {
        return $this->hasMany(Transaction::class);
    }
}
