Skip to content

Commit

Permalink
Fix getFiles query logic to prevent duplicate records by properly nes…
Browse files Browse the repository at this point in the history
…ting conditions
  • Loading branch information
m7moudabdel7mid committed Jul 25, 2024
1 parent 89b817d commit cec1aa2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Components/Modals/CuratorPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ public function getFiles(int $page = 0, bool $excludeSelected = false): array
return $query->where('directory', $this->directory);
})
->when($this->types, function ($query) {
$types = $this->types;
$query = $query->whereIn('type', $types);
$wildcardTypes = collect($types)->filter(fn ($type) => str_contains($type, '*'));
$wildcardTypes?->map(fn ($type) => $query->orWhere('type', 'LIKE', str_replace('*', '%', $type)));

return $query;
return $query->where(function($query){
$types = $this->types;
$query = $query->whereIn('type', $types);
$wildcardTypes = collect($types)->filter(fn ($type) => str_contains($type, '*'));
$wildcardTypes?->map(fn ($type) => $query->orWhere('type', 'LIKE', str_replace('*', '%', $type)));
});
})
->orderBy('created_at', $this->defaultSort);

Expand Down

0 comments on commit cec1aa2

Please sign in to comment.