I have a simple search/sort code snippet that I'm running on all of my models, and for some reason it is breaking on one of them. The model and controller file look pretty identical in what is brought in and such, so I'm not sure what the issue is. This code is designed to run off of URL tokens, such as: /doctors?search=bob&sortBy=first_name&sort=asc. Which works on all of my other models.
Code Block
// Searches, sorts, and filters
$search = $request->search;
$sort = ($request->sort == null ? 'asc' : $request->sort);
$sortBy = ($request->sortBy == null ? 'prescribe_date' : $request->sortBy);
This returns the following error: Undefined variable: request
And points to the lines in the code block above. I thought it might be because there was no ternary for a null search, but even fixing that points to the next $sort line.