在我的博客应用程序中,每个帖子都有一个特色图片,我想创建一个按年份和月份分组的图片相册,并将相册的第一个图片显示为相册封面,我已经按日期对帖子进行了分组,但问题是我无法将相册的第一个图片作为相册封面
下面是我如何按日期按博客帖子分组的
$postdates = App\Post::select(DB::raw('YEAR(created_at) year, MONTH(created_at) month, MONTHNAME(created_at) month_name, COUNT(*) post_count'))
->groupBy('year')
->groupBy('month')
->orderBy('year', 'desc')
->orderBy('month', 'desc')
->limit(12)
->get();
?>
问题是我认为在这里
@foreach($postdates as $postdate)
<li><a href="#"><img src="{{asset('images/'. $postdate->featured_image)}}" alt=""></a></li>
@endforeach
“featured_image”是表格中图像名称的列。