diff --git a/app/Models/Url.php b/app/Models/Url.php index 7d308c1..a32e234 100644 --- a/app/Models/Url.php +++ b/app/Models/Url.php @@ -158,4 +158,17 @@ public function urlSortable($query, $direction) return $query->join('domains', 'urls.domain_id', 'domains.id') ->orderBy($column, $direction); } + + /** + * Override default redirect URL sorting in order to sort URLs + * without their protocol. + * + * @param $query + * @param $direction + * @return mixed + */ + public function redirectUrlSortable($query, $direction) + { + return $query->orderBy(DB::raw("REPLACE(REPLACE(redirect_url, 'https://', ''), 'http://', '')"), $direction); + } }