【发布时间】:2015-03-03 04:51:14
【问题描述】:
我正在尝试使用 laravel-eloquent 来获取特定日期之后的房间及其预订。
$fdate='2015-01-05';
$roomdata=Rooms::where('city_id','=',$citydata['id'])
->with('types')
->with('localities')
->with('slideshow')
->with(array('booking' => function($query){
$query->where('bookstart','>',$fdate);
}))
->get();
这给了我一个错误,说 $fdate 未定义。但是当我这样做时
$query->where('bookstart','>','2015-01-05');
这很好用。这背后有什么原因吗?有人可以为这个问题提供一个好的解决方案吗?
【问题讨论】: