User Relationship with Permissions

I want a relationship that links to the Users tables, but that only returns a set of users with a certain permission. This is what I've got so far:

    public function assignee(): BelongsTo
    {
        return $this->belongsTo(User::class)
            ->whereHas('permissions', function ($query) {
                $query->where('name', 'manage Tickets');
            });
    }


It works to a point, but the dropdown I had on a form that worked perfectly before now shows the User ID rather than the Name. Can anyone advise please?
Was this page helpful?