<?php

namespace App\Domains\Authorization\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Permission extends Model
{
    protected $table = 'permisos';

    protected $fillable = [
        'codigo',
        'nombre',
        'descripcion',
    ];

    /**
     * @return BelongsToMany<Role, $this>
     */
    public function roles(): BelongsToMany
    {
        return $this->belongsToMany(
            Role::class,
            'roles_permisos',
            'codigo_permiso',
            'rol_codigo',
            'codigo',
            'codigo'
        )->withTimestamps();
    }
}
