<?php

namespace App\Http\Controllers;

use App\Models\Inventaris;
use Barryvdh\DomPDF\Facade\Pdf;

class InventarisController extends Controller
{
    public function viewInventarisPDF()
    {
        $inventaries = Inventaris::all();
        
        $filename = 'Inventaris.pdf';
        
        $pdf = Pdf::loadView('inventaris.inventaris', [
            'inventaries' => $inventaries
        ]);

        return $pdf->setPaper('a4', 'landscape')->stream($filename);
    }

    public function downloadInventarisPDF()
    {
        $inventaries = Inventaris::all();
        
        $filename = 'Inventaris.pdf';
        
        $pdf = Pdf::loadView('inventaris.inventaris', [
            'inventaries' => $inventaries
        ]);

        return $pdf->setPaper('a4', 'landscape')->download($filename);
    }
}
