'Purchase Order PDF Deleted', 'message' => 'You have successfully deleted the Purchase order PDF' ]; } /** @var FetchesBooking */ private $fetchesBooking; /** @var DeletesDocument */ private $deletesDocument; /** @var CanDeleteDocument */ private $canDeleteDocument; /** * DeletePurchaseOrderPdfLogic constructor. * @param FetchesBooking $fetchesBooking * @param DeletesDocument $deletesDocument * @param CanDeleteDocument $canDeleteDocument */ public function __construct(fetchesBooking $fetchesBooking, DeletesDocument $deletesDocument, CanDeleteDocument $canDeleteDocument) { $this->fetchesBooking = $fetchesBooking; $this->deletesDocument = $deletesDocument; $this->canDeleteDocument = $canDeleteDocument; } /** * @param Request $request * @return JsonResponse * @throws \App\Classes\Exceptions\MalformedRequestException */ public function logic(Request $request) : JsonResponse { $booking = $this->fetchesBooking->execute(['id' => $request->route('id')]); $document = $booking->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->first(); $this->canDeleteDocument->passes(); $this->deletesDocument->execute($document); return $this->response([]); } }