口才转换请求SQL

use*_*425 0 laravel laravel-5

我想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
Run Code Online (Sandbox Code Playgroud)

我在第二行之后陷入困境...

$Revision = Revision::where('fk_motorbike', $fk_motorbike)
->where('start_time', "<=", $time_start_training) ?
???
->first();
Run Code Online (Sandbox Code Playgroud)

我仍然是Laravel的初学者。

感谢您的帮助。

N69*_*69S 5

我猜这两个条件之间应该在括号内。

$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();
Run Code Online (Sandbox Code Playgroud)