Skip to content

Commit

Permalink
Strip protocol when sorting redirect URL
Browse files Browse the repository at this point in the history
  • Loading branch information
NFarrington committed Nov 3, 2019
1 parent 6f64d47 commit 7e36501
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/Models/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 7e36501

Please sign in to comment.