Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bvlinsky committed Sep 21, 2023
1 parent c72e48f commit bde10a1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/Dtos/OrderIndexDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static function instantiateFromRequest(FormRequest|OrderIndexRequest $req
{
return new self(
search: $request->input('search'),
sort: $request->input('sort'),
sort: $request->input('sort', 'created_at:desc'),
status_id: $request->input('status_id'),
shipping_method_id: $request->input('shipping_method_id'),
);
Expand Down
3 changes: 2 additions & 1 deletion app/Events/ProductSearchValueEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace App\Events;

use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class ProductSearchValueEvent
class ProductSearchValueEvent implements ShouldQueue
{
use Dispatchable;
use SerializesModels;
Expand Down
12 changes: 8 additions & 4 deletions app/Services/AttributeOptionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
use App\Services\Contracts\MetadataServiceContract;
use Heseya\Dto\Missing;

class AttributeOptionService implements AttributeOptionServiceContract
readonly class AttributeOptionService implements AttributeOptionServiceContract
{
public function __construct(private MetadataServiceContract $metadataService) {}
public function __construct(
private MetadataServiceContract $metadataService,
) {}

public function create(string $attributeId, AttributeOptionDto $dto): AttributeOption
{
Expand All @@ -22,7 +24,9 @@ public function create(string $attributeId, AttributeOptionDto $dto): AttributeO
],
$dto->toArray(),
);
$attributeOption = AttributeOption::create($data);

/** @var AttributeOption $attributeOption */
$attributeOption = AttributeOption::query()->create($data);

if (!($dto->getMetadata() instanceof Missing)) {
$this->metadataService->sync($attributeOption, $dto->getMetadata());
Expand All @@ -35,7 +39,7 @@ public function updateOrCreate(string $attributeId, AttributeOptionDto $dto): At
{
if ($dto->id !== null && !$dto->id instanceof Missing) {
/** @var AttributeOption $attributeOption */
$attributeOption = AttributeOption::findOrFail($dto->id);
$attributeOption = AttributeOption::query()->findOrFail($dto->id);
$attributeOption->update($dto->toArray());

ProductSearchValueEvent::dispatch($attributeOption->productAttributes->pluck('product_id')->toArray());
Expand Down

0 comments on commit bde10a1

Please sign in to comment.