Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: model not implementing has media should only throw exception if no custom callback is provided #2494

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Http/Controllers/Admin/FeaturedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
($bucketable['scopes'] ?? []) + ($scopes ?? []),
$bucketable['orders'] ?? [],
$bucketable['per_page'] ?? $request->get('offset') ?? 10,
$forcePagination = true
true

Check warning on line 167 in src/Http/Controllers/Admin/FeaturedController.php

View check run for this annotation

Codecov / codecov/patch

src/Http/Controllers/Admin/FeaturedController.php#L167

Added line #L167 was not covered by tests
)->appends('bucketable', $module);

$fetchedModules[$module] = $items;
Expand Down
8 changes: 4 additions & 4 deletions src/Services/Listings/Columns/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ public function toColumnArray(array $visibleColumns = [], bool $sortable = true)

protected function getRenderValue(TwillModelContract $model): string
{
if (!classHasTrait($model::class, HasMedias::class)) {
throw new InvalidArgumentException('Cannot use image column on model not implementing HasMedias trait');
}

if ($renderFunction = $this->render) {
return $renderFunction($model);
}

if (!classHasTrait($model::class, HasMedias::class)) {
throw new InvalidArgumentException('Cannot use image column on model not implementing HasMedias trait');
}

return $this->getThumbnail($model);
}

Expand Down
Loading