mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
74 lines
2.0 KiB
PHP
74 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\PackingLists\Services\DeletesPackingList;
|
|
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
|
use App\Classes\Modules\PackingLists\Standards\Rules\CanDeletePackingList;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class DeletePackingListLogic extends AbstractControllerLogic
|
|
{
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Deleted PackingList',
|
|
'message' => 'You have successfully deleted a PackingList'
|
|
];
|
|
}
|
|
|
|
|
|
/** @var CanDeletePackingList */
|
|
private $canDeletePackingList;
|
|
|
|
/** @var DeletesPackingList */
|
|
private $deletesPackingList;
|
|
|
|
/** @var FetchesPackingList */
|
|
private $fetchesPackingList;
|
|
|
|
/**
|
|
* DeletePackingListControllersLogic constructor.
|
|
* @param CanDeletePackingList $canDeletePackingList
|
|
* @param DeletesPackingList $deletesPackingList
|
|
* @param FetchesPackingList $fetchesPackingList
|
|
*/
|
|
public function __construct(CanDeletePackingList $canDeletePackingList, DeletesPackingList $deletesPackingList, FetchesPackingList $fetchesPackingList)
|
|
{
|
|
$this->canDeletePackingList = $canDeletePackingList;
|
|
$this->deletesPackingList = $deletesPackingList;
|
|
$this->fetchesPackingList = $fetchesPackingList;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
try {
|
|
|
|
$this->canDeletePackingList->passes();
|
|
|
|
$query = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
|
|
|
$this->deletesPackingList->execute($query);
|
|
|
|
return $this->response([]);
|
|
|
|
} catch (\Exception $exception){
|
|
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
|
}
|
|
|
|
}
|
|
|
|
}
|