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');
});
}
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?
1 Reply
Hightower
HightowerOP3w ago
In fact, it doesn't show an ID I don't believe - it just shows a number 1 Sussed it with 'roles.permissions' in the query
Want results from more Discord servers?
Add your server