0
public function extract(){
$occupation = Occupation::join('invoices', 'occupations.id', '=', 'invoices.occupation_id')
->leftJoin('payments', 'invoices.id', '=', 'payments.invoice_id')
->select('occupations.*',
'invoices.occupation_id',
'invoices.id as invoiceId',
'invoices.date_invoice',
'invoices.date_pay',
'invoices.ufir as invoiceUfir',
'payments.date_payment',
'payments.value')
->find(1);
return view('occupation/extract', ['occupation' => $occupation]);
}
This is my Controller.
@foreach($occupation as $o)
<tr>
<td>{{ $o->invoiceId }}</td>
<td>{{ date('m/Y', strtotime($o->date_invoice)) }}</td>
<td>{{ date('d/m/Y', strtotime($o->date_pay)) }}</td>
<td>{{ number_format(($o->invoiceUfir), 2, ',', '.') }}</td>
<td></td>
<td></td>
<td></td>
<td>{{ date('d/m/Y', strtotime($o->date_payment)) }}</td>
<td>{{ number_format($o->value, 2, ',', '.') }}</td>
<td></td>
</tr>
@endforeach
This is my Blade.
When I put it without @foreach it works perfectly, now when I put it to bring the other information from the bug:
"Trying to get Property '***' of non-object (View: C: Users grosa Desktop Laravel siscom Resources views occupation Extract.blade.php)".
I look forward to your support. I thank you in advance for your cooperation.
Give a balcony like the object is leaving your controller a "dd" on it after the query runs
– Luiz Didier
If you are selecting only one record,
find(1)
, why do you want to do theforeach
?– Woss
True, I forgot I was with find(1), but when I put the get() it runs from dd() quiet, but in Blade it gives the following error "Property [id] does not exist on this Collection instance."
– Guilherme Rosa
And what was the exit from
dd
? Put to the question...– Woss