mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 04:24:00 +00:00
39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Orders\Services;
|
|
|
|
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
|
use App\Classes\Modules\Orders\DataTransferObjects\AddressObject;
|
|
use App\Classes\ValueObjects\Constants\HttpStatus;
|
|
use App\Models\Order;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class UpdatesOrderAddress
|
|
{
|
|
/** @var Order */
|
|
private $repository;
|
|
|
|
/**
|
|
* UpdatesOrderAddress constructor.
|
|
* @param Order $repository
|
|
*/
|
|
public function __construct(Order $repository)
|
|
{
|
|
$this->repository = $repository;
|
|
}
|
|
|
|
|
|
public function execute(string $orderId,string $addressId){
|
|
try{
|
|
|
|
$repository = $this->repository->findOrFail($orderId);
|
|
$repository->address_id = $addressId;
|
|
$repository->save();
|
|
return new JsonResponse([],HttpStatus::OK);
|
|
|
|
}catch (\Exception $exception){
|
|
|
|
throw new InternalServerErrorException("Failed to update address because {$exception->getMessage()}");
|
|
}
|
|
}
|
|
} |