Postingan lainnya
Bagaimana print/cetak PDF setelah data di filter?
Bagaimana print pdf setelah data di filter, sebelumnya sudah bisa cetak pdf namun data yang tercetak secara keseluruhan, dan setelah difiler kemudian diprint, data hasil print/cetakan masih tampil keseluruhan, dengan controller seperti berikut :
public function fun_pdf(Request $request)
{
$pendidikan = $request->education_id;
$jurusan = $request->major_id;
$jobseekers = Jobseeker::with('educations','religions','sexes','marrieds','majors')->get();
$pdf = PDF::loadView('jobseekers.pdfvieww',compact('jobseekers'));
$pdf->setPaper('A4', 'landscape');
return $pdf->stream('rekapan.pdf');
}
berikut adalah tampilan data sebelum di filter :<a href=' https://imgur.com/y8ac6hv '> https://imgur.com/y8ac6hv </a> kemudian print pdf : <a href='https://imgur.com/SffNRPi '>https://imgur.com/SffNRPi </a> kemudian data di filter seperti berikut :<a href='https://imgur.com/6ZweAS7 '>https://imgur.com/6ZweAS7 </a> , lalu saya cetak pdf, hasil sama seperti ini : <a href='https://imgur.com/SffNRPi '>https://imgur.com/SffNRPi </a> bagaimana membuat cetak pdf, data sebelum dan sesudah di filter? dengan view pada cetak pdf seperti berikut :
<table class="table table-sm table-responsive-sm table-bordered table-hover">
<thead>
<tr>
<th>NIK</th>
<th>No.Pendaftaran</th>
<th>Nama</th>
{{-- <th>Jenis Kelamin</th> --}}
<th>Pendidikan</th>
<th>Jurusan</th>
<th>No.Telepon</th>
<th>Email</th>
{{-- <th>email2</th> --}}
</tr>
</thead>
<tbody>
@php
$no = 1;
@endphp
@foreach($jobseekers as $data)
<tr>
<td>{{ $data->nik }}</td>
<td>{{ $data->nomor_pendaftaran }}</td>
<td>{{ $data->nama }}</td>
{{-- <td>{{ $data->sexes->nama}}</td> --}}
<td>
{{ $data->educations->nama }}
{{-- @if (!Empty($jobseekers->education->nama) )
{{ $jobseekers->education->nama }}
@else
{{ " "}}
@endif --}}
</td>
<td>
{{ $data->majors->nama }}
{{-- @if (!Empty($jobseekers->major->nama) )
{{ $jobseekers->major->nama }}
@else
{{ " "}}
@endif --}}
</td>
<td>{{ $data->nomor_hp }}</td>
<td>{{ $data->email }}</td>
</tr>
@php
$no++;
@endphp
@endforeach
</tbody>
</table>
mohon pencerahannya kak, terimakasih
2 Jawaban:
@yenimulya, di Controller itu datanya belum terfilter (Masih mengambil semua data), coba ganti seperti ini
$jobseekers = Jobseeker::with('educations','religions','sexes','marrieds','majors')
->where([
['education_id' , $pendidikan],
['major_id' , $jurusan]
])->get();
@Cristal sudah saya ganti namun ketika dicetak datanya malah kosong kak, baik setelah difilter atau sebelum difilter. Apakah harus ada perubahan dalam coding viewnya?