Files
shipping-portal/app/Classes/Modules/ContainerPackingLists/ControllersLogic/DeleteContainerPackingListLogic.php
T
2021-07-24 11:39:40 +08:00

74 lines
2.4 KiB
PHP

<?php
namespace App\Classes\Modules\ContainerPackingLists\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\ContainerPackingLists\Services\DeletesContainerPackingList;
use App\Classes\Modules\ContainerPackingLists\Services\FetchesContainerPackingList;
use App\Classes\Modules\ContainerPackingLists\Standards\Rules\CanDeleteContainerPackingList;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class DeleteContainerPackingListLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Deleted ContainerPackingList',
'message' => 'You have successfully deleted a ContainerPackingList'
];
}
/** @var CanDeleteContainerPackingList */
private $canDeleteContainerPackingList;
/** @var DeletesContainerPackingList */
private $deletesContainerPackingList;
/** @var FetchesContainerPackingList */
private $fetchesContainerPackingList;
/**
* DeleteContainerPackingListControllersLogic constructor.
* @param CanDeleteContainerPackingList $canDeleteContainerPackingList
* @param DeletesContainerPackingList $deletesContainerPackingList
* @param FetchesContainerPackingList $fetchesContainerPackingList
*/
public function __construct(CanDeleteContainerPackingList $canDeleteContainerPackingList, DeletesContainerPackingList $deletesContainerPackingList, FetchesContainerPackingList $fetchesContainerPackingList)
{
$this->canDeleteContainerPackingList = $canDeleteContainerPackingList;
$this->deletesContainerPackingList = $deletesContainerPackingList;
$this->fetchesContainerPackingList = $fetchesContainerPackingList;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
try {
$this->canDeleteContainerPackingList->passes();
$query = $this->fetchesContainerPackingList->execute(['id' => $request->route('id')]);
$this->deletesContainerPackingList->execute($query);
return $this->response([]);
} catch (\Exception $exception){
throw new ErrorException($exception->getMessage(), $exception->getCode());
}
}
}