The link posted by @Guilherme-reis is from 2012 and may not solve your problem.
The Typeahead.js is a jQuery plugin made by the guys who made the Bootstrap.
In this article of scotch io. they explain how to use Laravel and Typeahead.
Summary:
HTML:
<input type="search" name="q" class="form-control" placeholder="Search" autocomplete="off">
Javascript:
jQuery(document).ready(function($) {
// Set the Options for "Bloodhound" suggestion engine
var engine = new Bloodhound({
remote: {
url: '/find?q=%QUERY%',
wildcard: '%QUERY%'
},
datumTokenizer: Bloodhound.tokenizers.whitespace('q'),
queryTokenizer: Bloodhound.tokenizers.whitespace
});
$(".search-input").typeahead({
hint: true,
highlight: true,
minLength: 1
}, {
source: engine.ttAdapter(),
// This will be appended to "tt-dataset-" to form the class name of the suggestion menu.
name: 'usersList',
// the key from the array we want to display (name,id,email,etc...)
templates: {
empty: [
'<div class="list-group search-results-dropdown"><div class="list-group-item">Nothing found.</div></div>'
],
header: [
'<div class="list-group search-results-dropdown">'
],
suggestion: function (data) {
return '<a href="' + data.profile.username + '" class="list-group-item">' + data.name + '- @' + data.profile.username + '</a>'
}
}
});
});
Route:
Route::get('find', 'SearchController@find');
Searchcontroller:
public function find(Request $request)
{
return User::search($request->get('q'))->with('profile')->get();
}
The author uses a trait so that models have better functionality search: nicolaslopezj/searchable
The article contains details of model implementation and subject matter deepening.