mirror of
https://gitlab.com/omair-personal/izyim.git
synced 2026-08-22 13:53:57 +00:00
41 lines
956 B
PHP
41 lines
956 B
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Orders\Services;
|
|
|
|
|
|
use App\Classes\Modules\Accounts\Exceptions\CannotUpdateOrderWarehouseException;
|
|
use App\Models\OrderWarehouse;
|
|
|
|
class UpdatesOrderWarehouse
|
|
{
|
|
|
|
/** @var OrderWarehouse */
|
|
private $repository;
|
|
|
|
/**
|
|
* SetsOrderWarehouse constructor.
|
|
* @param OrderWarehouse $repository
|
|
*/
|
|
public function __construct(OrderWarehouse $repository)
|
|
{
|
|
$this->repository = $repository;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param int $orderId
|
|
* @param $warehouseId
|
|
* @param $type
|
|
* @throws CannotUpdateOrderWarehouseException
|
|
*/
|
|
public function execute(int $orderId, $warehouseId, $type){
|
|
try {
|
|
$this->repository->updateOrCreate(['order_id' => $orderId, 'type' =>$type], ['warehouse_id' => $warehouseId]);
|
|
|
|
} catch (\Exception $exception){
|
|
throw new CannotUpdateOrderWarehouseException($exception->getMessage());
|
|
}
|
|
|
|
}
|
|
|
|
} |