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 of the error:
"Trying to get property '***' of non-object (View: C: \ Users \ gros \ Desktop \ Laravel \ siscom \ resources \ views \ occupation \ extract.blade.php) >
I look forward to your support. Thank you in advance for your cooperation.