我想request
在Laravel Eloquent中将其转换为以下内容。
select * from revision where fk_motorbike = NumberMoto and start_time between time_start_training and time_stop_training or start_stop between time_start_training and time_stop_training
我在第二行之后陷入困境...
$Revision = Revision::where('fk_motorbike', $fk_motorbike) ->where('start_time', "<=", $time_start_training) ? ??? ->first();
我仍然是Laravel的初学者。
感谢您的帮助。
我猜这两个条件之间应该在括号内。
$Revision = Revision::where('fk_motorbike', $fk_motorbike)
->where(function($query) use($time_start_training, $time_stop_training) {
$query->whereBetween('start_time', [$time_start_training, $time_stop_training])
->orWhereBetween('start_stop', [$time_start_training, $time_stop_training]);
})
->first();