<?php

namespace App\Domains\Menu\Models;

use App\Domains\Tenant\Models\Tenant;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Menu extends Model
{
    use HasFactory;

    protected $table = 'menues';

    protected $fillable = [
        'code',
        'route',
    ];

    public function tenants(): BelongsToMany
    {
        return $this->belongsToMany(
            Tenant::class,
            'tenant_menues',
            'menu_code',
            'tenant_codigo',
            'code',
            'codigo'
        )->withTimestamps();
    }
}
