0
Good night.
What I need is to display the name of the book where your id is (in the Form Book column). And so that I don’t do it in a way outside the convention, I’d like to know the right way to do it.
I have the method dashboard that’s in the controller Homecontroller which passes to my view the objects below to form the table:
public function painel(){
$livro = Livro::all();
$lote = Lote::all();
$status = Status::all();
return view('painel.index', compact('livro', 'lote', 'status'));
}
And I also have the controller Lotecontroller where from there I would need to pass to that same view 'index panel.' the book name (book->title) and not the book id that is in the Lot table (lot->book_id).
I would like to know the correct way to do such a procedure. If I’m wrong in the way I’m doing, I’m free to take criticism to improve my code. Thank you!
View panel.index:
div class="container">
<h1>Consulta de Lotes</h1>
<table class="table">
<thead class="thead-dark">
<tr>
<th>Lote</th>
<th>Livro</th>
<th>Data Início</th>
<th>Data de Encerramento</th>
</tr>
</thead>
<tbody>
@foreach ($lote as $lotes)
<tr>
<th>{{ $lotes->id }}</th>
<th>{{ $lotes->livro_id }}</th>
<th>{{ $lotes->dia_inicio }}</th>
<th>{{ $lotes->dia_fim }}</th>
</tr>
@endforeach
</tbody>
</table>
</div>
Thanks friend. I did so right there while waiting for the answers. But anyway I need to separate each thing in its model (class), to make coherent.
– Willians Macena