@jlrdw So my issue is that my image doesn't load where I use filters, but loads where I don't use them like this:
<img src="{{ asset($image->getFirstMediaUrl('image')) }}"
I was reading this https://spatie.be/docs/laravel-medialibrary/v10/basic-usage/retrieving-media
and this https://spatie.be/docs/laravel-medialibrary/v10/converting-images/retrieving-converted-images
So I'm not sure why wouldn't that work in that case
The thing is, the component works on a different page.
However I've noticed my pagination doesn't work where the filter is - so maybe that's the issue I need to solve first.
Yep! Something here is breaking the code it seems
public function scopeFilter($query, array $filters) {
$query->when($filters['color'] ?? false, fn($query, $color) =>
$query->whereHas('site.color', function ($query) use ($color) {
$query->where('name', $color);
})->get()
);
$query->when($filters['page'] ?? false, fn($query, $page) =>
$query->whereHas('categoryPage', function ($query) use ($page) {
$query->where('name', $page);
})->get()
);
$theme = $filters['theme'] ?? 'light';
$device = $filters['device'] ?? 'desktop';
$query->with('imageVariations', function($query) use ($theme, $device) {
$query->join('site_variations', 'site_variation_id', 'site_variations.id')
->where('site_variations.theme', $theme)
->where('site_variations.device', $device);
})->get();
}
And to be exact, this code here breaks the image:
$query->with('imageVariations', function($query) use ($theme, $device) {
$query->join('site_variations', 'site_variation_id', 'site_variations.id')
->where('site_variations.theme', $theme)
->where('site_variations.device', $device);
})->get();
And the code above that breaks the pagination xd
So I have some issues with the filter, I guess that's the main issue.
And I can see why the above would break the pagination, because I'm using a reserved word for pagination here:
// $query->when($filters['page'] ?? false, fn($query, $page) =>
// $query->whereHas('categoryPage', function ($query) use ($page) {
// $query->where('name', $page);
// })->get()
// );
filters page.... but that's actually used for pagination, which means I need to change that to be something else and that should fix the filter.
So in that case just need to fix the image breaking form the below xd Yeah, I did that and it works, I just fixed myself the pagination lol totally unrelated to this.
In that case the other piece of code breaks the image for some reason. So I think need new question for that.