Skip to content

Instantly share code, notes, and snippets.

@polodev
Last active March 16, 2022 10:37
Show Gist options
  • Save polodev/1cf8c3b4b3a44caa5b9bb78823af5346 to your computer and use it in GitHub Desktop.
Save polodev/1cf8c3b4b3a44caa5b9bb78823af5346 to your computer and use it in GitHub Desktop.
if (request()->has('starting_date') && request('starting_date')) {
  $query->wheredate('created_at', '>=', request('starting_date'));
}
if (request()->has('ending_date') && request('ending_date')) {
  $query->whereDate('created_at', '<=', request('ending_date'));
}

raw sql from debugbar

select count(*) as aggregate from `orders` where `company_id` in ('9') and `operational_status` in ('underwriting_done') and date(`created_at`) >= '2022-03-01' and date(`created_at`) <= '2022-03-15' and `orders`.`deleted_at` is null

result showing for date(created_at) >= '2022-03-05'

what happen with query?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment