You can easly do this creating an ajax request and loading in the page on success
First create a route
Route::get('search', 'SearchController@find');
Then create the method in the Controller
// app/Http/Controllers/SearchController.php
public function find(Request $request)
{
$query = User::select('*');
if ($request->input('q')) {
$query->where('name', 'like', "%{$request->input('name')}%");
}
$results = $query->orderBy('created_at', 'desc')->get();
return view('search.find', compact('results'));
}
and finally in you javascript you can do something like this, i suppose that you're using jQuery.
$(document).on('submit', 'form#search', function (e) {
var q = $(this).find('input[name=q']).val();
$.ajax({
type: 'GET',
dataType: 'html',
url: '/search',
data: {
q: q
},
success: function (data) {
// Do some nice animation to show results
$('#searchdata').html(data);
}
});
e.preventDefault();
});
This is a simple way to do this.