Undefined variable: data error occure when i want to display data from database. here is my code
//Controller
public function filter(Request $request)
{
$data = Trial::where('zipcode',$request->zipcode)->select('lat','lng')->first();
$lat = $data->lat;
$lng = $data->lng;
$distance = 5 ;// Diatanse in kms
$query = Trial::getByDistance($lat, $lng, $distance);
$ids = [];
//Extract the id's
if(!empty($query)) {
foreach($query as $q)
{
array_push($ids, $q->id);
}
}
// Now write final query
if(!empty($ids)){
$results = DB::table('trial')->whereIn( 'id', $ids)->where('zipcode');
}
return view('search.searchhome',compact('data',$data));
dd($data);
}
// Blade
<p>
@foreach($data as $dat)
@endforeach
</p>
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2I0XYM8
via IFTTT
Aucun commentaire:
Enregistrer un commentaire