public function delete($id = null) { $dataPost = $this->request->getJsonRawBody(); foreach ($dataPost->anexos_id as $anexo_id) { $anexo = Anexo::findFirst($anexo_id); unlink($anexo->getCaminho()); $anexo->getProjetoAnexos()->delete(); $anexo->delete(); } return PostResponse::createResponse(true, "Anexos removidos com sucesso"); }
public function download($id) { $anexo = Anexo::findFirst($id); $response = new Response(); if ($anexo) { $response->setStatusCode(StatusCodes::OK); $response->setFileToSend($anexo->getCaminho(), $anexo->getOriginal()); } else { $response->setStatusCode(StatusCodes::NAO_ENCONTRADO); } return $response; }