Last active
September 8, 2021 06:51
-
-
Save DengoPHP/d3e95441a7b9e27299b7 to your computer and use it in GitHub Desktop.
Laravel Eloquent with Subselect and Advanced Where
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| DB::table('rooms') | |
| ->whereNotIn('room_id', function($query) | |
| { | |
| $query->select('room_id') | |
| ->from(with(new Booking)->getTable()) | |
| ->where(function($query) | |
| { | |
| $query->where('time_out', '<', '2012-09-14T18:00') | |
| ->orWhere('time_in', '>', '2012-09-21T09:00'); | |
| }); | |
| }) | |
| ->orderBy('room_id') | |
| ->get(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can leave this in your route.php to see the Query
Event::listen('illuminate.query', function()
{
echo '<pre>';
var_dump(func_get_args());
echo '</pre>';
});