Skip to content

Commit

Permalink
optimize query
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsn committed Sep 28, 2023
1 parent 0b3c089 commit 6d5e8b3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Models/TagModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,10 @@ public function getByIds(array $ids, string $type): array
foreach ($tagIds as $tag) {
$taggableToTags[$tag['taggable_id']][] = $tag['tag_id'];
}
$tagIds = array_map('intval', array_column($tagIds, 'tag_id'));

$tagIds = array_map('intval', array_unique(array_column($tagIds, 'tag_id')));
$tags = $this->find($tagIds);
$tagIds = array_column($tags, 'id');
$tags = array_combine($tagIds, $tags);
$tags = array_column($tags, null, 'id');

$results = [];

Expand Down

0 comments on commit 6d5e8b3

Please sign in to comment.