Skip to content

Commit c9a25ef

Browse files
committed
Using resumed dates for exact_year and exact_day types for search URL
1 parent c980087 commit c9a25ef

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/Controllers/TicketsController.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,18 @@ public function register_search_fields(Request $request)
962962
// Build this search URL
963963
$search_URL = route(Setting::grab('main_route') . '.search');
964964
foreach($search_fields as $field => $value){
965+
if (in_array($field, $this->a_search_fields_date)){
966+
$carbon_instance = Carbon::createFromFormat(trans('panichd::lang.datetime-format'), $value);
967+
if($search_fields[$field . '_type'] == 'exact_year'){
968+
// If a date field type is "exact_year", show only year in URL
969+
$value = $carbon_instance->format('Y');
970+
971+
}elseif($search_fields[$field . '_type'] == 'exact_day'){
972+
// If a date field type is "exact_day", show only locale datetime string in URL
973+
$value = $carbon_instance->format(trans('panichd::lang.date-format'));
974+
}
975+
976+
}
965977
$search_URL.= '/' . $field . '/' . (is_array($value) ? implode(',', $value) : $value);
966978
}
967979

0 commit comments

Comments
 (0)