mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 04:24:00 +00:00
44 lines
1023 B
PHP
44 lines
1023 B
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Orders\Services;
|
|
|
|
|
|
use App\Classes\Modules\Accounts\Exceptions\CannotUpdateOrderWarehouseException;
|
|
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
|
use App\Models\Order;
|
|
|
|
class SetsOrderWarehouse
|
|
{
|
|
|
|
/** @var Order */
|
|
private $repository;
|
|
|
|
/**
|
|
* SetsOrderWarehouse constructor.
|
|
* @param Order $repository
|
|
*/
|
|
public function __construct(Order $repository)
|
|
{
|
|
$this->repository = $repository;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param OrderObject $order
|
|
* @throws CannotUpdateOrderWarehouseException
|
|
*/
|
|
public function execute(OrderObject $order){
|
|
try {
|
|
|
|
/** @var Order $repository */
|
|
$repository = $this->repository->findOrFail($order->getOrderId());
|
|
$repository->warehouse_id = $order->getWarehouseId();
|
|
$repository->save();
|
|
|
|
} catch (\Exception $exception){
|
|
throw new CannotUpdateOrderWarehouseException($exception->getMessage());
|
|
}
|
|
|
|
}
|
|
|
|
} |