Skip to content
This repository was archived by the owner on Sep 27, 2022. It is now read-only.

Commit e2a5c8e

Browse files
author
Sandeesh
committed
Moved item sort inside paginator.
This is to prevent 'Mixing of GROUP columns' error on strict mode on accessing count() on builder.
1 parent 1ccd9ae commit e2a5c8e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

app/Http/Controllers/Api/ArticleController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(ArticleTransformer $transformer)
3434
*/
3535
public function index(ArticleFilter $filter)
3636
{
37-
$articles = new Paginator(Article::latest()->loadRelations()->filter($filter));
37+
$articles = new Paginator(Article::loadRelations()->filter($filter));
3838

3939
return $this->respondWithPagination($articles);
4040
}

app/Paginate/Paginator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(Builder $builder, $limit = 20, $offset = 0)
3535

3636
$this->total = $builder->count();
3737

38-
$this->data = $builder->skip($offset)->take($limit)->get();
38+
$this->data = $builder->latest()->skip($offset)->take($limit)->get();
3939
}
4040

4141
/**

app/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function feed()
7979
{
8080
$followingIds = $this->following()->pluck('id')->toArray();
8181

82-
return Article::latest()->loadRelations()->whereIn('user_id', $followingIds);
82+
return Article::loadRelations()->whereIn('user_id', $followingIds);
8383
}
8484

8585
/**

0 commit comments

Comments
 (0)