Skip to content

Commit

Permalink
Update CommentService.php
Browse files Browse the repository at this point in the history
  • Loading branch information
iooe committed Feb 19, 2019
1 parent 6ca0f25 commit f553d88
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/UseCases/CommentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ public static function isCommentable($model): bool
*/
public static function orderByRequestAdapter(GetRequest $request): array
{
if ($request->order_by === 'rating') {
return ['column' => 'rating', 'direction' => 'desc'];
}
return ['column' => 'id', 'direction' => 'asc'];
$order_direction = $request->order_direction === 'asc' || $request->order_direction === 'desc'
? $request->order_direction : 'asc';

$order_by = $request->order_by === 'rating' ? $request->order_by : 'id';

return ['column' => $order_by, 'direction' => $order_direction];
}


Expand Down

0 comments on commit f553d88

Please sign in to comment.