Hello, I'm using DomPDF to try to return a report in pdf, but every time I call the view it loads like it's in an infinite loop and nothing happens. Follow my code CourseController.php
public function downloadPDF($id)
{
$curso = Curso::find($id);
$alunos = $curso->alunos;
$pdf = PDF::loadView('curso.pdf', compact('curso', 'alunos'));
return $pdf->download('invoice.pdf');
}
My route is calling like this:
Route::get('/cursos/{id}/pdf','CursoController@downloadPDF');
And the view I want to call is pdf.blade.php
@extends('master')
@section('content')
<div class="container">
<h2>{{$curso->nome}}</h2>
<br>
<div class="pull-right">
</div>
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Nome</th>
<th>Nascimento</th>
<th>logradouro</th>
<th>No</th>
<th>Bairro</th>
<th>Cidade</th>
<th>Estado</th>
<th>Dt. Criação</th>
</tr>
</thead>
<tbody>
@foreach($alunos as $value)
<tr>
<td>{{$value->id}}</td>
<td>{{$value->nome}}</td>
<td>{{$value->data_nascimento}}</td>
<td>{{$value->logradouro}}</td>
<td>{{$value->numero}}</td>
<td>{{$value->bairro}}</td>
<td>{{$value->cidade}}</td>
<td>{{$value->estado}}</td>
<td>{{ date( 'd/m/Y' , strtotime($value->created_at))}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
I was able to generate the pdf by putting only one