<?php

declare(strict_types=1);

namespace Builder\Core\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Foundation\Auth\User;

final class Role extends Model
{
    protected $table = 'roles';

    /** @var list<string> */
    protected $fillable = ['name', 'display_name', 'description'];

    /** @return BelongsToMany<User, $this> */
    public function users(): BelongsToMany
    {
        /** @var class-string<User> $userModel */
        $userModel = config('auth.providers.users.model', User::class);

        return $this->belongsToMany($userModel, 'role_user');
    }
}
