Configurable parameters
Opened this issue · 0 comments
robbielove commented
I would like it if the params 'direction', 'sort' were hardcoded as a default config setting rather than hardcoded in general.
Personally, I prefer to use 'order' as 'direction' and it causes the need for both parameters in the URL because I just use 'order' and force it to populate direction so that sortable works.
This would also allow them to be translated too.
eg. something like this (i just got a random bit of code)
$sortParamName = config('columnsortable.sort_param_name', 'sort');
$directionParamName = config('columnsortable.direction_param_name', 'direction');
if (is_string($array)) {
return [$sortParamName => $array, $directionParamName => $defaultDirection];
}
return (key($array) === 0) ? [$sortParamName => $array[0], $directionParamName => $defaultDirection] : [
$sortParamName => key($array),
$directionParamName => reset($array),
];