Skip to content

Commit

Permalink
update FilterBetweenDates
Browse files Browse the repository at this point in the history
  • Loading branch information
maks-oleksyuk committed Dec 22, 2024
1 parent a5434e2 commit cdcede9
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 96 deletions.
10 changes: 5 additions & 5 deletions app/Models/Traits/DynamicScopes/FilterBetweenDatesScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace App\Models\Traits\DynamicScopes;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;

/**
* @template TModel of Model
Expand All @@ -20,11 +20,11 @@ trait FilterBetweenDatesScope
public function scopeFilterBetweenDates(
Builder $query,
string $column,
string $start_date,
string $end_date,
Carbon $startDate,
Carbon $endDate,
): Builder {
return $query
->where($column, '>=', Carbon::parse($start_date)->startOfDay())
->where($column, '<=', Carbon::parse($end_date)->endOfDay());
->where($column, '>=', $startDate->startOfDay())
->where($column, '<=', $endDate->endOfDay());
}
}
Loading

0 comments on commit cdcede9

Please sign in to comment.