Skip to content

Instantly share code, notes, and snippets.

@alfredoem
Last active February 20, 2016 11:49
Show Gist options
  • Save alfredoem/9c6637e05f41a4ab659b to your computer and use it in GitHub Desktop.
Save alfredoem/9c6637e05f41a4ab659b to your computer and use it in GitHub Desktop.
/*jQuery UI - Laravel 5*/
/*Search Selection*/
$(function() {
$(".input-search-selection").autocomplete({
source: function(request, response) {
$.ajax({
url: "{{url('sec-menus/menus-by-field')}}",
dataType: 'json',
data: {
searchValue: $('.input-search-selection').val(),
searchField: $('#searchField').val()
}
}).success(function(data){
response(data);
});
},
select: function( event, ui ) {
console.log(ui.item.value);
},
minLength: 2
});
});
/*controller ej.*/
public function getMenusByField(Request $request)
{
$data = \DB::table('SecMenus')
->select("{$request->searchField} as label")
->where($request->searchField, 'LIKE', '%' . $request->searchValue .'%')
->get();
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment