Commit 120fe191 authored by PedroLopesUPE's avatar PedroLopesUPE
Browse files

Adição da função de salvar PDF em sistema

parent ff346de2
Showing with 14 additions and 3 deletions
+14 -3
...@@ -118,12 +118,15 @@ class UserPadController extends Controller ...@@ -118,12 +118,15 @@ class UserPadController extends Controller
} }
/** /**
* Generate PDF, with a given user_pad_id * Return generated PDF, with a given user_pad_id;
*
* Additionally, if a filename is given, function will save PDF in storage;
* *
* @param integer $user_pad_id * @param integer $user_pad_id
* @param string $fileName
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function generatePDF($user_pad_id) public function generatePDF($user_pad_id, $fileName="")
{ {
$niveis = Nivel::listNivel(); $niveis = Nivel::listNivel();
$funcoes = Funcao::listFuncaoEnsino() + $funcoes = Funcao::listFuncaoEnsino() +
...@@ -400,6 +403,14 @@ class UserPadController extends Controller ...@@ -400,6 +403,14 @@ class UserPadController extends Controller
$pdf_name = " Relatório PAD - " . $userPad->user->{'name'}; $pdf_name = " Relatório PAD - " . $userPad->user->{'name'};
$pdf = PDF::loadView('pad.teacher.report_pdf', $data); $pdf = PDF::loadView('pad.teacher.report_pdf', $data);
if ($fileName == "")
{
return $pdf->download($pdf_name . ".pdf"); return $pdf->download($pdf_name . ".pdf");
} }
else
{
$pdf->save($fileName);
}
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment