I have a SearchController for my Searchable models, in my case it looks like this
class SearchController extends Controller
{
use Searchable;
public function searchUsers(Request $request) {
$query = $request->input('query');
$users = User::search($query)
->get()
->except([Auth::id()])
->take(10);
// \Log::info(Auth::id());
return response()->json($users);
}
}
When this piece of code runs, I get an error in my logs saying that the line with theexcept method throws and error of: Attempt to read property "id" on null {"exception":"[object] (ErrorException(code: 0): Attempt to read property \"id\" on null at C:\\Users... Logs also showed that Auth::id() returns null, but besides that I have no idea what is happening here. Any help is appreciated, thanks!