I'm following this tutorial to make filters on my site.
I'm trying to add an OR statement within the filter in the HTML.
For example,
<a href="{{ route('rooms.index',
['type' => request('type'),
'sort' => request('sort'),
'region' => 'Lisbon'|'Lisboa',
]) }}">Lisbon</a>
However, if I do this, only results for "Lisbon" appear, but those for "Lisboa" do not.
I have also tried
'region' => ('Lisbon|Lisboa'),
'region' => ('Lisbon||Lisboa'),
'region' => array('Lisbon','Lisboa'),
['region' => 'Lisbon', 'region' => 'Lisboa',],
all with no luck. It seems like when there is a comma between "Lisbon" and "Lisboa" that the operator only looks at the first option, "Lisbon" in this case.
(If you're wondering, Google Maps API gives me either Lisbon or Lisboa for the admin district, even though I have restricted it to English.)
Then, for my controller, here is how I am doing the filters:
public function index()
{
$rooms = new Room;
if (request()->has('type')) {
$rooms = $rooms->where('type', request('type'));
}
if (request()->has('region')) {
$rooms = $rooms->where('region', request('region'));
}
if (request()->has('sort')) {
$rooms = $rooms->orderBy('created_at', request('sort'));
}
$rooms = $rooms->paginate(20)->appends([
'type' => request('type'),
'region' => request('region'),
'sort' => request('sort'),
]);
return view('rooms.index')->with('rooms', $rooms);
Any idea what could be a possible solution here?
Thanks!
('Lisbon')|('Lisboa'). This evaluates to a string ofLisboo.