File tree Expand file tree Collapse file tree 8 files changed +72
-0
lines changed Expand file tree Collapse file tree 8 files changed +72
-0
lines changed Original file line number Diff line number Diff line change
1
+ <div class =" mb-3 mb-md-0 input-group" >
2
+ <input
3
+ wire:model =" filters.{{ $key } }"
4
+ wire:key =" filter-{{ $key } }"
5
+ id =" filter-{{ $key } }"
6
+ type =" datetime-local"
7
+ @if (isset ($filter -> options [' min' ]) && strlen ($filter -> options [' min' ]) ) min =" {{ $filter -> options [' min' ] } }" @endif
8
+ @if (isset ($filter -> options [' max' ]) && strlen ($filter -> options [' max' ]) ) max =" {{ $filter -> options [' max' ] } }" @endif
9
+ class =" form-control"
10
+ />
11
+ </div >
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ class="dropdown-menu w-100 mt-md-3"
42
42
@include (' livewire-tables::bootstrap-4.includes.filter-type-multiselect' )
43
43
@elseif ($filter -> isDate () )
44
44
@include (' livewire-tables::bootstrap-4.includes.filter-type-date' )
45
+ @elseif ($filter -> isDatetime () )
46
+ @include (' livewire-tables::bootstrap-4.includes.filter-type-datetime' )
45
47
@endif
46
48
</div >
47
49
@endforeach
Original file line number Diff line number Diff line change
1
+ <div class =" flex rounded-md shadow-sm mt-1" >
2
+ <input
3
+ wire:model =" filters.{{ $key } }"
4
+ wire:key =" filter-{{ $key } }"
5
+ id =" filter-{{ $key } }"
6
+ type =" datetime-local"
7
+ @if (isset ($filter -> options [' min' ]) && strlen ($filter -> options [' min' ]) ) min =" {{ $filter -> options [' min' ] } }" @endif
8
+ @if (isset ($filter -> options [' max' ]) && strlen ($filter -> options [' max' ]) ) max =" {{ $filter -> options [' max' ] } }" @endif
9
+ class =" form-control"
10
+ />
11
+ </div >
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ class="dropdown-menu w-100"
42
42
@include (' livewire-tables::bootstrap-5.includes.filter-type-multiselect' )
43
43
@elseif ($filter -> isDate () )
44
44
@include (' livewire-tables::bootstrap-5.includes.filter-type-date' )
45
+ @elseif ($filter -> isDatetime () )
46
+ @include (' livewire-tables::bootstrap-5.includes.filter-type-datetime' )
45
47
@endif
46
48
</div >
47
49
@endforeach
Original file line number Diff line number Diff line change
1
+ <div class =" flex rounded-md shadow-sm mt-1" >
2
+ <input
3
+ wire:model.stop =" filters.{{ $key } }"
4
+ wire:key =" filter-{{ $key } }"
5
+ id =" filter-{{ $key } }"
6
+ type =" datetime-local"
7
+ @if (isset ($filter -> options [' min' ]) && strlen ($filter -> options [' min' ]) ) min =" {{ $filter -> options [' min' ] } }" @endif
8
+ @if (isset ($filter -> options [' max' ]) && strlen ($filter -> options [' max' ]) ) max =" {{ $filter -> options [' max' ] } }" @endif
9
+ class =" block w-full border-gray-300 rounded-md shadow-sm transition duration-150 ease-in-out focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-800 dark:text-white dark:border-gray-600"
10
+ />
11
+ </div >
Original file line number Diff line number Diff line change @@ -62,6 +62,8 @@ class="block text-sm font-medium leading-5 text-gray-700 dark:text-white">
62
62
@include (' livewire-tables::tailwind.includes.filter-type-multiselect' )
63
63
@elseif ($filter -> isDate () )
64
64
@include (' livewire-tables::tailwind.includes.filter-type-date' )
65
+ @elseif ($filter -> isDatetime () )
66
+ @include (' livewire-tables::tailwind.includes.filter-type-datetime' )
65
67
@endif
66
68
</div >
67
69
</div >
Original file line number Diff line number Diff line change @@ -192,6 +192,15 @@ public function cleanFilters(): void
192
192
return $ dt !== false && ! array_sum ($ dt ::getLastErrors ());
193
193
}
194
194
195
+ if ($ filterDefinitions [$ filterName ]->isDatetime ()) {
196
+ // array_sum trick is a terse way of ensuring that PHP
197
+ // did not do "month shifting"
198
+ // (e.g. consider that January 32 is February 1)
199
+ $ dt = DateTime::createFromFormat ("Y-m-d\TH:i " , $ filterValue );
200
+
201
+ return $ dt !== false && ! array_sum ($ dt ::getLastErrors ());
202
+ }
203
+
195
204
return false ;
196
205
})->toArray ();
197
206
}
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ class Filter
9
9
{
10
10
public const TYPE_DATE = 'date ' ;
11
11
12
+ public const TYPE_DATETIME_LOCAL = 'datetime-local ' ;
13
+
12
14
public const TYPE_SELECT = 'select ' ;
13
15
14
16
public const TYPE_MULTISELECT = 'multiselect ' ;
@@ -96,6 +98,20 @@ public function date(array $options = []): Filter
96
98
return $ this ;
97
99
}
98
100
101
+ /**
102
+ * @param array $options
103
+ *
104
+ * @return $this
105
+ */
106
+ public function datetime (array $ options = []): Filter
107
+ {
108
+ $ this ->type = self ::TYPE_DATETIME_LOCAL ;
109
+
110
+ $ this ->options = $ options ;
111
+
112
+ return $ this ;
113
+ }
114
+
99
115
/**
100
116
* @return string
101
117
*/
@@ -135,4 +151,12 @@ public function isDate(): bool
135
151
{
136
152
return $ this ->type === self ::TYPE_DATE ;
137
153
}
154
+
155
+ /**
156
+ * @return bool
157
+ */
158
+ public function isDatetime (): bool
159
+ {
160
+ return $ this ->type === self ::TYPE_DATETIME_LOCAL ;
161
+ }
138
162
}
You can’t perform that action at this time.
0 commit comments