diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index a2a7dbb12..a69755387 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -2,7 +2,6 @@ namespace App\Http\Controllers; -use App\Events\ProductSearchValueEvent; use App\Http\Requests\TagCreateRequest; use App\Http\Requests\TagIndexRequest; use App\Http\Requests\TagUpdateRequest; @@ -35,16 +34,13 @@ public function store(TagCreateRequest $request): JsonResource public function update(Tag $tag, TagUpdateRequest $request): JsonResource { $tag->update($request->validated()); - ProductSearchValueEvent::dispatch($tag->products->pluck('id')->toArray()); return TagResource::make($tag); } public function destroy(Tag $tag): HttpResponse { - $products = $tag->products->pluck('id')->toArray(); $tag->delete(); - ProductSearchValueEvent::dispatch($products); return Response::noContent(); } diff --git a/app/Services/AttributeOptionService.php b/app/Services/AttributeOptionService.php index cd73a0b75..1e3111da6 100644 --- a/app/Services/AttributeOptionService.php +++ b/app/Services/AttributeOptionService.php @@ -3,7 +3,6 @@ namespace App\Services; use App\Dtos\AttributeOptionDto; -use App\Events\ProductSearchValueEvent; use App\Models\AttributeOption; use App\Services\Contracts\AttributeOptionServiceContract; use App\Services\Contracts\MetadataServiceContract; @@ -42,8 +41,6 @@ public function updateOrCreate(string $attributeId, AttributeOptionDto $dto): At $attributeOption = AttributeOption::query()->findOrFail($dto->id); $attributeOption->update($dto->toArray()); - ProductSearchValueEvent::dispatch($attributeOption->productAttributes->pluck('product_id')->toArray()); - return $attributeOption; } @@ -52,9 +49,7 @@ public function updateOrCreate(string $attributeId, AttributeOptionDto $dto): At public function delete(AttributeOption $attributeOption): void { - $productIds = $attributeOption->productAttributes->pluck('product_id')->toArray(); $attributeOption->delete(); - ProductSearchValueEvent::dispatch($productIds); } public function deleteAll(string $attributeId): void diff --git a/app/Services/AttributeService.php b/app/Services/AttributeService.php index 824a103c7..e061cb734 100644 --- a/app/Services/AttributeService.php +++ b/app/Services/AttributeService.php @@ -4,7 +4,6 @@ use App\Dtos\AttributeDto; use App\Enums\AttributeType; -use App\Events\ProductSearchValueEvent; use App\Models\Attribute; use App\Models\Product; use App\Services\Contracts\AttributeOptionServiceContract; @@ -35,18 +34,15 @@ public function create(AttributeDto $dto): Attribute public function update(Attribute $attribute, AttributeDto $dto): Attribute { $attribute->update($dto->toArray()); - ProductSearchValueEvent::dispatch($attribute->products->pluck('id')->toArray()); return $attribute; } public function delete(Attribute $attribute): void { - $products = $attribute->products->pluck('id')->toArray(); $this->attributeOptionService->deleteAll($attribute->getKey()); $attribute->delete(); - ProductSearchValueEvent::dispatch($products); } public function sync(Product $product, array $data): void diff --git a/app/Services/ProductSetService.php b/app/Services/ProductSetService.php index eeed98c6e..387d49c6c 100644 --- a/app/Services/ProductSetService.php +++ b/app/Services/ProductSetService.php @@ -5,7 +5,6 @@ use App\Dtos\ProductSetDto; use App\Dtos\ProductSetUpdateDto; use App\Dtos\ProductsReorderDto; -use App\Events\ProductSearchValueEvent; use App\Events\ProductSetCreated; use App\Events\ProductSetDeleted; use App\Events\ProductSetUpdated; @@ -117,8 +116,6 @@ public function create(ProductSetDto $dto): ProductSet $this->metadataService->sync($set, $dto->metadata); } - ProductSearchValueEvent::dispatch($set->allProductsIds()->toArray()); - // searchable is handled by the event listener ProductSetCreated::dispatch($set); @@ -204,7 +201,6 @@ public function update(ProductSet $set, ProductSetUpdateDto $dto): ProductSet 'slug' => $slug, 'public_parent' => $publicParent, ]); - ProductSearchValueEvent::dispatch($productIds->toArray()); if (!($dto->getAttributesIds() instanceof Missing)) { $attributes = Collection::make($dto->getAttributesIds()); @@ -233,23 +229,13 @@ public function reorder(array $sets, ProductSet|null $parent = null): void public function attach(ProductSet $set, array $productsIds): Collection { - $currentProducts = $set->products()->pluck('id'); - $set->products()->sync($productsIds); - ProductSearchValueEvent::dispatch( - array_merge( - $currentProducts->diff($productsIds)->toArray(), - collect($productsIds)->diff($currentProducts)->toArray(), - ), - ); - return $set->products; } public function delete(ProductSet $set): void { - $productIds = $set->allProductsIds()->merge($set->relatedProducts->pluck('id')); if ($set->children()->count() > 0) { $set->children->each(fn ($subset) => $this->delete($subset)); } @@ -259,7 +245,6 @@ public function delete(ProductSet $set): void if ($set->seo !== null) { $this->seoMetadataService->delete($set->seo); } - ProductSearchValueEvent::dispatch($productIds->toArray()); } }