feat(entry): refine variant selection logic to exclude replaced variants and add unit tests for replacement behavior
This commit is contained in:
@@ -12,7 +12,7 @@ class EntryResource extends JsonResource
|
||||
/** @return array<string, mixed> */
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$variant = $this->variants->sole();
|
||||
$variant = $this->variants->whereNull('replaced_by_variant_id')->sole();
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
|
||||
@@ -97,6 +97,7 @@ class EntryService
|
||||
|
||||
$variants = Variant::query()
|
||||
->where('catalog_item_id', $catalogItem->id)
|
||||
->whereNull('replaced_by_variant_id')
|
||||
->lockForUpdate()
|
||||
->get();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user