i create export pdf on MY TABLE data , so this table no need $id like i export profile user or anything ,
but in this table i have search date range in this table ,and this result will can export pdf by Dompdf .
this is my controller :
public function journal_sarpras()
{
$ipsrs_id = Auth::user()->roles->ipsrs_id;
$journal = Aduan::with('users')->where('ipsrs_id',$ipsrs_id)->orderBy('created_at', 'desc')->paginate(10);
return view('sarpras.journal_sarpras',['journal' => $journal ]);
}
-
public function search_range(Request $request)
{
$ipsrs_id = Auth::user()->roles->ipsrs_id;
$from = $request->from;
$to = $request->to;
$status = $request->status;
if($status == 'Belum Selesai'){
$new_status =['Tindakan Lanjutan' , 'Belum Dikerjakan' ,'Sedang Dikerjakan'];
}
elseif($status == 'Semua Laporan'){
$new_status = ['Tindakan Lanjutan' , 'Belum Dikerjakan', 'Sedang Dikerjakan' , 'Selesai'];
}
else{
$new_status = 'Selesai';
}
$stats = collect($new_status);
$journal = Aduan::where('ipsrs_id',$ipsrs_id)->whereIn('status',$stats)
->whereBetween('created_at', [$request->get('from'), $request->get('to')])->paginate();
//dd($aduan);
return view('sarpras.journal_sarpras',['journal' => $journal]);
}
-
public function getPDF($journal){
$pdf = PDF::loadView('file_pdf', ['journal' => $journal]);
dd($pdf);
return $pdf->stream('file_pdf.pdf')->header('Content-Type','application/pdf');
}
this 3 controller is View Table ,View Search Date range and export Pdf .on this export pdf i using variable on search pdf to parse this data in view like data viewed on table.
and this is my route
Route::get('getPDF', 'AdminController@getPDF')->name('getPDF');
and parsing on this view
<a href="{{route('getPDF')}}" class="btn btn-primary" target="_blank">CETAK PDF</a>
but this is having error
Too few arguments to function App\Http\Controllers\AdminController::getPDF(), 0 passed and exactly 1 expected
what wrong with this pdf ?