0

I am using Laravel 4 for web development. I defined a Model called Author and Author could post article. then i need a list of authors, which ordered by the latest article, and the name of authors could not be duplicate. I using the code like

$authors= Author::LeftJoin('articles','author.id','=','articles.author_id')
        ->orderBy('articles.created_at','DESC');
        ->groupBy('author.id')->paginate(16);

this note work well. the authors are order by the first article not the last. could groupBy work on the first row occurred?

Oldskool
  • 34,211
  • 7
  • 53
  • 66
ArchenZhang
  • 151
  • 2
  • 8

0 Answers0