I have this where I get all my tournaments $tournaments = Tournament::all();
. Now I want to let the user filter these on the go in the view... I would like to have an <input>
where the user enters a few characters and then the results filter on tournaments that have those characters in the name.
I have found this* online but I dont know how to populate that $keyword
. It would be best if the results filter after every character that is entered in the inputfield. If this is not possible, then make this a form that sends this $keyword
to Controller and retrieves the new results on the same page!
* $tournament = Tournament::where('name', 'LIKE', '%'.$keyword.'%')->get();
How do I do this? I don't know... Please provide some code in the answer.
Thx
Are you wondering how to get the input of a posted value? You can use the Input::get()
method.
$keyword = Input::get('keyword');
if(isset($keyword)){
$tournaments = Tournament::where('name', 'LIKE', "%$keyword%")->get();
}else{
$tournaments = Tournament::all();
}
Also can also use jQuery UI Autocomplete function to progressively search for results.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With