There is page template “product”, which contains files sections with 3 different file templates (product photos, drawings photos, detailes photos). I need to show first image of “product photos” as thumb in panel. Using this model:
<?php
class CategoryPage extends Page
{
public function cover()
{
return $this->content()->get('cover')->toFile() ?? $this->files()->filterBy('template','productphotos')->sortBy('sort', 'asc')->first();
}
}
It works well for templates, but in panel shows first image of all images. How to make filter by file tempalte work in panel?
Your page model refers to a CategoryPage type, however, in your pages section, you are using pages with the product template. So you cover method defined in the CategoryPage model won’t apply.