I'm trying to do the implementation of this pure php project (Re-write pure PHP code in Laravel-5.1 format) in Laravel-5.1 version, and I'm yet to get what needs to be done right. Bootstrap Typeahead is not effected. I would appreciate being pointed to what I'm to do right.
This is the blade form:
{!! Form::open(array('url' => 'created-products', 'method' => 'post'), array('id'=>'createproduct')) !!}
{!! Form::token() !!}
<link href="{!! asset('bootstrap/css/bootstrap.css') !!}" media="all" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="style.css">
<script src="http://ift.tt/oHTnA7"></script>
<p>{!! Form::select('countries', array('-1' => 'Select a Country') + $listedCountries) !!} </p>
<p>{!! Form::text('typeahead', null, array('class'=>'well', 'placeholder'=>'enter your state'), array('id'=>'selectedCompanyHiddenId', 'data-provider'=>'typeahead')) !!}</p>
<script src="http://ift.tt/1HheyD3"></script>
<script src="{!! asset('bootstrap/js/bootstrap.js') !!}" media="all" rel="stylesheet" />
<script>
$(function(){
$('#typeahead').typeahead({
source: function(query, process){
$.ajax({
url: 'UserAddressController.php',
type: 'POST',
data: 'query=' +query,
dataType: 'JSON',
async: true,
success: function(data){
process(data);
}
});
}
});
});
</script>
{!! Form::close() !!}
THis is the controller:
public function create()
{
$listedCountries = $this->showListedCountries();
return view('useraddress.create')
->with('listedCountries', $listedCountries)
->with('returnedLocationPlaces', $this->SelectLocationPlaces());
}
THe method returning the records:
public function SelectLocationPlaces($query = "")
{
$locationPlaces = LocationPlaces::where('name', 'like', "%{$query}%")->get();
return json_encode($locationPlaces);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire