以下根据他们提交的作品数量显示前50位艺术家:
查询:
$artists_most_popular = DB::table('artists')
->join('fanartists', 'artists.id', '=', 'fanartists.artist_id')
->select(DB::raw('artists.*, fanartists.*, COUNT(*) AS total_artists'))
->orderBy('total_artists', 'DESC'))
->groupBy('artists.id')
->take(50)
->get();
查看:
rank | artist | pieces
<?php $i = 1 ?>
@foreach($users as $user)
{{ $i }} | {{ $artist->name }} | 0
<?php $i++ ?>
@endforeach
如何让0显示计数?例如,如果艺术家出现在7行上,则该数字为7。