I have an array of dates for example
array:5 [
0 => "2021-12-06"
1 => "2021-12-07"
2 => "2021-12-08"
3 => "2021-12-09"
4 => "2021-12-10"
]
And I have a database table called clinic_dates
| id| clinic_id | start_date | end_date
|:---- |:------:| -----:|-----:|
start_date and end_date fields are datetime fields
I want to get all fields from clinic dates fields that aren't at the array using laravel eloquent .
CodePudding user response:
I am trying to make a mix between whereNotIn and whereDate but can't make it
CodePudding user response:
Are your dates strings or Carbon
instances? You can match on a string with a LIKE query, since we're not checking the times.
If they're Carbon
instances, first use $str = $date->format('Y-m-d');
first.
$query = Clinics::query();
foreach ($dates as $date) {
$query->where('start_date', 'not LIKE', $date.'%')
->where('end_date', 'not LIKE', $date.'%');
}