Nvd\Crud\Html::sortableTh PHP Method

sortableTh() public static method

public static sortableTh ( $fieldName, $route, $label = null )
    public static function sortableTh($fieldName, $route, $label = null)
    {
        $output = "<th>";
        $sortType = "asc";
        if (Request::input("sort") == $fieldName and Request::input("sortType") == "asc") {
            $sortType = "desc";
        }
        $params = array_merge(Request::query(), ['sort' => $fieldName, 'sortType' => $sortType]);
        $href = route($route, $params);
        $output .= "<a href='{$href}'>";
        $label = $label ?: ucwords(str_replace("_", " ", $fieldName));
        $output .= $label;
        if (Request::input("sort") == $fieldName) {
            $output .= " <i class='fa fa-sort-alpha-" . Request::input("sortType") . "'></i>";
        }
        $output .= "</a>";
        $output .= "</th>";
        return $output;
    }