fix: user search n+1

- eager load group relation
This commit is contained in:
HDVinnie
2020-12-07 21:54:28 -05:00
parent f01a153fa9
commit 6bfc553b32
2 changed files with 1 additions and 4 deletions
+1
View File
@@ -50,6 +50,7 @@ class UserSearch extends Component
{
return view('livewire.user-search', [
'users' => User::query()
->with('group')
->when($this->searchTerm, function ($query) {
return $query->where('username', 'LIKE', '%'.$this->searchTerm.'%')->orWhere('email', 'LIKE', '%'.$this->searchTerm.'%');
})
@@ -60,10 +60,6 @@
<td>
<span class="badge-user text-bold">
{{ $user->username }}
@if ($user->warnings_count > 0)
<i class="{{ config('other.font-awesome') }} fa-exclamation-circle text-orange" aria-hidden="true"
data-toggle="tooltip" data-original-title="@lang('common.active-warning')"></i>
@endif
</span>
</td>
<td>