【发布时间】:2018-01-30 05:30:52
【问题描述】:
是 HotelController 内部的结果函数。
public function result()
{
$data=Input::except(array('_token'));
$city= $data['city'];
$cities_id = DB::table('cities')
->select('id')
->where('cities.city_name', 'LIKE', "%$city%")
->get();
$hotel = array();
foreach ($cities_id as $value) {
$i=$value->id;
$hotel[] = DB::table('add_hotels')
->select('id')
->where('city_id', '=', $i)
->get();
}
var_dump($hotel);
exit();
return view('hotel.result',compact('hotel','city'));
}
这是我得到的结果,但我只需要用红色框标记的数据
【问题讨论】:
-
请看附图以便更好地理解...
标签: php mysql laravel laravel-query-builder