group where conditions in laravel

Solutions on MaxInterview for group where conditions in laravel by the best coders in the world

showing results for - "group where conditions in laravel"
Nyle
28 Nov 2019
1<?php
2
3$results = DB::table('table')
4             ->where(function($query) use ($starttime,$endtime){
5                 $query->where('starttime', '<=', $starttime);
6                 $query->where('endtime', '>=', $endtime);
7             })
8             ->orWhere(function($query) use ($otherStarttime,$otherEndtime){
9                 $query->where('starttime', '<=', $otherStarttime);
10                 $query->where('endtime', '>=', $otherEndtime);
11             })
12             ->orWhere(function($query) use ($anotherStarttime,$anotherEndtime){
13                 $query->where('starttime', '>=', $anotherStarttime);
14                 $query->where('endtime', '<=', $anotherEndtime);
15             })
16             ->get();
17