<?php

namespace App\Domains\Menu\Models;

use App\Domains\Tenant\Models\Tenant;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\Pivot;

class TenantMenu extends Pivot
{
    protected $table = 'tenants_menues';

    public $incrementing = true;

    protected $fillable = [
        'tenant_code',
        'menu_code',
        'static_content',
    ];

    protected function casts(): array
    {
        return [
            'static_content' => 'array',
        ];
    }

    public function tenant(): BelongsTo
    {
        return $this->belongsTo(Tenant::class, 'tenant_code', 'codigo');
    }

    public function menu(): BelongsTo
    {
        return $this->belongsTo(Menu::class, 'menu_code', 'code');
    }
}
