The link posted by @ guilherme-reis is 2012 and may not solve your problem.
Typeahead.js is a jQuery plugin made by the guys who made Bootstrap.
In this scotch.io article 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 for models to have better search functionality: nicolaslopezj / searchable
The article contains details of the model's implementation and deepening of the subject.