feat: add helper file
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!function_exists('generateSortRouteParameter')) {
|
||||||
|
function generateSortRouteParameter(string $sortKey): array
|
||||||
|
{
|
||||||
|
|
||||||
|
return array_merge(request()->query(), ['sort' => $sortKey]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('activeSort')) {
|
||||||
|
function activeSort(string $sortKey, string $default = ''): string
|
||||||
|
{
|
||||||
|
$currentSort = request()->query('sort', $default);
|
||||||
|
|
||||||
|
|
||||||
|
if ($currentSort === $sortKey) {
|
||||||
|
return 'bg-blue-500 text-white font-DanaMedium';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'text-gray-600 dark:text-gray-300 hover:text-blue-500';
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user