MIF_E31221451/app/Http/Controllers/PDF/StudentGrowthController.php

27 lines
683 B
PHP

<?php
namespace App\Http\Controllers\PDF;
use Carbon\Carbon;
use App\Models\Student;
use Barryvdh\DomPDF\Facade\Pdf;
use App\Http\Controllers\Controller;
class StudentGrowthController extends Controller
{
public function generate(Student $student)
{
$growths = $student->growths()->with('user')->get();
Carbon::setLocale('id');
$tanggal = Carbon::now()->translatedFormat('d F Y');
$pdf = Pdf::loadView('PDF.student-growth', [
'student' => $student,
'growths' => $growths,
])->setPaper('A4', 'portrait');
return $pdf->download("LAPORAN_PERKEMBANGAN_SISWA_{$student->name}_{$tanggal}.pdf");
}
}