'Deleted Document', 'message' => 'You have successfully deleted a document' ]; } /** @var FetchesDocument */ private $fetchesDocument; /** @var DeletesDocument */ private $deletesDocument; /** @var CanDeleteDocument */ private $canDeleteDocument; /** * DeleteDocumentLogic constructor. * @param FetchesDocument $fetchesDocument * @param DeletesDocument $deletesDocument * @param CanDeleteDocument $canDeleteDocument */ public function __construct(FetchesDocument $fetchesDocument, DeletesDocument $deletesDocument, CanDeleteDocument $canDeleteDocument) { $this->fetchesDocument = $fetchesDocument; $this->deletesDocument = $deletesDocument; $this->canDeleteDocument = $canDeleteDocument; } /** * @param Request $request * @return JsonResponse * @throws \App\Classes\Exceptions\MalformedRequestException */ public function logic(Request $request) : JsonResponse { $document = $this->fetchesDocument->execute(['id' => $request->route('id')]); $this->canDeleteDocument->passes(); $this->deletesDocument->execute($document); return $this->response([]); } }