Files
izyim/app/Classes/Modules/Orders/Services/UpdatesOrderWarehouse.php
T
Omair Saleh 0e5f2939e3 large commit
2019-10-05 13:09:26 +08:00

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());
}
}
}