https://prnt.sc/gh6hcrYv6NSO Attempt to read property "id" on int
veya string olarak bu hatayı veriyor.
Array olarak alıyorum oysa ki kayıtları tam olarak nerede hatam var dd çıktısını da ekledim.
Action::make('print')
->label('Yazdır')
->icon('heroicon-o-printer')
->action(function ($record) {
$pdfdata = [
//'fileName' => 'pfc.pdf',
'ID' => $record->id,
'barcode_number' => $record->barcode_number,
];
view()->share('employee',$pdfdata);
$pdf = \Barryvdh\DomPDF\Facade\Pdf::loadView('pdf/pdf_view', $pdfdata);
// download PDF file with download method
return $pdf->download('pdf_file.pdf');
}),
View blade
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Laravel 7 PDF Example</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link href="{{ asset('css/app.css') }}" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container mt-5">
<h2 class="text-center mb-3">Laravel HTML to PDF Example</h2>
<div class="d-flex justify-content-end mb-4">
<a class="btn btn-primary" href="{{ URL::to('#') }}">Export to PDF</a>
</div>
<table class="table table-bordered mb-5">
<thead>
<tr class="table-danger">
<th scope="col">ID</th>
<th scope="col">barcode_number</th>
</tr>
</thead>
<tbody>
@foreach($employee ?? '' as $data)
<tr>
<th scope="row">{{ $data->id }}</th>
<td>{{ $data->barcode_number }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<script src="{{ asset('js/app.js') }}" type="text/js"></script>
</body>
</html>