ekart/backend/app/Actions/RemoveProductFromCartAction.php
kusowl 5bbec0ee2b feature: update quantity and remove product from cart
add endpoint for update quantity of products (min:1, max:10)
add endpoint for removing product from cart
2026-03-10 19:01:52 +05:30

22 lines
458 B
PHP

<?php
namespace App\Actions;
use App\Models\User;
final readonly class RemoveProductFromCartAction
{
public function __construct(private GetActiveUserCartAction $activeCartAction) {}
/**
* Execute the action.
*/
public function execute(int $productId, User $user)
{
$cart = $user->carts()->active()->sole();
$cart->products()->detach($productId);
return $this->activeCartAction->execute($user);
}
}