get('search', ''); $query = User::query()->orderBy('name', 'desc') ->take(20); if (!empty($search)) { $query->where(function(Builder $query) use ($search) { $query->where('email', 'like', '%' . $search . '%') ->orWhere('name', 'like', '%' . $search . '%'); }); } $users = $query->get(); return view('components.user-select-list', compact('users')); } }