Skip to content

Commit

Permalink
Format Code
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeFourkas authored and github-actions[bot] committed Aug 12, 2024
1 parent ceda60c commit 3acb607
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ function get_media_items(array | Media | int $ids): Collection | array
return [$ids];
}

if(is_array($ids) && is_related_to_media_through_pivot(get_class(current($ids)), Media::class)){
$mediaIds = collect($ids)->map(fn ($model) => $model?->media_id)->toArray();
if (is_array($ids) && is_related_to_media_through_pivot(get_class(current($ids)), Media::class)) {
$mediaIds = collect($ids)->map(fn ($model) => $model?->media_id)->toArray();

return Media::whereIn('id', $mediaIds)->get();
}


$ids = array_values($ids);

if (isset($ids[0]['id'])) {
Expand All @@ -47,9 +46,8 @@ function get_media_items(array | Media | int $ids): Collection | array
}
}


if (! function_exists('is_related_to_media_through_pivot')) {
function is_related_to_media_through_pivot(string $modelClass, string $relatedClass):bool
function is_related_to_media_through_pivot(string $modelClass, string $relatedClass): bool
{
$model = new $modelClass;
$reflector = new \ReflectionClass($model);
Expand All @@ -66,6 +64,7 @@ function is_related_to_media_through_pivot(string $modelClass, string $relatedCl
}
}
}

return false;
}
}
Expand Down

0 comments on commit 3acb607

Please sign in to comment.