|
@@ -4,6 +4,7 @@ namespace App\Filament\Company\Pages\Concerns;
|
4
|
4
|
|
5
|
5
|
use Filament\Actions\Action;
|
6
|
6
|
use Filament\Forms\Components\DatePicker;
|
|
7
|
+use Filament\Forms\Components\DateTimePicker;
|
7
|
8
|
use Filament\Forms\Form;
|
8
|
9
|
use Illuminate\Support\Arr;
|
9
|
10
|
use Illuminate\Support\Carbon;
|
|
@@ -170,9 +171,25 @@ trait HasDeferredFiltersForm
|
170
|
171
|
$flatFields = $this->getFiltersForm()->getFlatFields();
|
171
|
172
|
|
172
|
173
|
foreach ($this->filters as $key => $value) {
|
173
|
|
- if (isset($flatFields[$key]) && $flatFields[$key] instanceof DatePicker) {
|
174
|
|
- // TODO: Submit a PR to Filament to address DatePicker being dehydrated as a datetime string in filters
|
175
|
|
- $this->filters[$key] = Carbon::parse($value)->toDateString();
|
|
174
|
+ if (! isset($flatFields[$key]) || blank($value)) {
|
|
175
|
+ continue;
|
|
176
|
+ }
|
|
177
|
+
|
|
178
|
+ $field = $flatFields[$key];
|
|
179
|
+
|
|
180
|
+ // Reproduce underlying conversion to UTC for DateTimePicker and DatePicker
|
|
181
|
+ if ($field instanceof DateTimePicker && $field->getTimezone() !== config('app.timezone')) {
|
|
182
|
+ try {
|
|
183
|
+ $carbonValue = Carbon::parse($value, $field->getTimezone());
|
|
184
|
+
|
|
185
|
+ // Shift back to UTC and format according to field type
|
|
186
|
+ $this->filters[$key] = $carbonValue
|
|
187
|
+ ->setTimezone(config('app.timezone'))
|
|
188
|
+ ->format($field->getFormat());
|
|
189
|
+
|
|
190
|
+ } catch (\Exception $e) {
|
|
191
|
+ continue;
|
|
192
|
+ }
|
176
|
193
|
}
|
177
|
194
|
}
|
178
|
195
|
}
|