我在div中有一个图像和标题标记,如何将它们与心爱的图像对齐.
<div class="clearfix">
<img src="http://localhost/chifley-acf/wp-content/uploads/2017/03/icon-01.png" alt="Icon" class="pull-left">
<h4>Refinancing</h4>
</div>
Run Code Online (Sandbox Code Playgroud)
像这样的电流输出
但我想要这样
我有两个表具有一对多关系。
预订- (id)
booking_tasks- (id, booking_id,user_id)
一项预订有很多任务一项任务有一个预订
预订模式:
public function tasks() {
return $this->hasMany('App\BookingTask');
}
Run Code Online (Sandbox Code Playgroud)
BookingTask模型
public function booking() {
return $this->belongsTo('App\Booking');
}
Run Code Online (Sandbox Code Playgroud)
我想获取预订列表,其中user_id = 2代表最新的booking_task。我不想检查其他旧的Booking_tasks。
例如:
我想检查booking_task的user_id = 2的最后一条记录,然后将其作为预订。在示例中,最后的booking_task的user_id =5。因此,它不会作为预订。
我的代码是:
$bookings=Booking::whereHas('tasks',function($q){
$q->where('user_id',2);//this will check whether any of record has user_id =2
})->get();
Run Code Online (Sandbox Code Playgroud)
我也用过:但这不是正确的方法,
$bookings=Booking::whereHas('tasks',function($q){
$q->latest()->where('user_id',2)->limit(1);//this will check whether any of record has user_id =2 and return latest one.
})->get();
Run Code Online (Sandbox Code Playgroud)
我可以解决这个问题,我也必须使用Laravel Eloquent。