Tambah logging untuk penanganan error saat generate PDF
- Menambahkan fungsi try-catch di `PenilaiController` untuk menangani kesalahan saat proses pembuatan file PDF. - Menggunakan `Illuminate\Support\Facades\Log` untuk mencatat error yang terjadi. - Memperbaiki format dan layout pada file blade `print-out.blade.php` agar lebih konsisten.
This commit is contained in:
@@ -13,6 +13,7 @@ use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Exports\KertasKerjaExport;
|
||||
use Modules\Lpj\Http\Controllers\SurveyorController;
|
||||
use Modules\Location\Models\Province;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PenilaiController extends Controller
|
||||
{
|
||||
@@ -607,20 +608,24 @@ class PenilaiController extends Controller
|
||||
$lpjData = json_decode($lpj->lpj, true);
|
||||
}
|
||||
|
||||
try {
|
||||
$pdf = PDF::loadView('lpj::penilai.components.print-out', compact(
|
||||
'permohonan',
|
||||
'forminspeksi',
|
||||
'lpjData',
|
||||
'formFoto',
|
||||
'basicData',
|
||||
'inspeksi',
|
||||
'lpj'
|
||||
));
|
||||
|
||||
$pdf = PDF::loadView('lpj::penilai.components.print-out', compact(
|
||||
'permohonan',
|
||||
'forminspeksi',
|
||||
'lpjData',
|
||||
'formFoto',
|
||||
'basicData',
|
||||
'inspeksi',
|
||||
'lpj'
|
||||
));
|
||||
$pdf->setPaper('A4', 'portrait');
|
||||
|
||||
$pdf->setPaper('A4', 'portrait');
|
||||
|
||||
return $pdf->download('laporan.pdf');
|
||||
return $pdf->download('laporan.pdf');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('PDF generation failed: ' . $e->getMessage());
|
||||
return response()->json(['error' => 'Failed to generate PDF. Please check the log for details.'], 500);
|
||||
}
|
||||
|
||||
// return view('lpj::penilai.components.print-out', compact(
|
||||
// 'permohonan',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user