Property [x] does not exist on this collection instance using with() with polymorphic

Viewed 100

I get this error Property [status] does not exist on this collection instance when I am trying to get the value of the column, here is my code

$lab = Lab::select('id', 'services_cat_id', 'resp_doctor_id', 'invoice_id', 'xray_file', 'status', 'note')->where('patient_id', '3')
        ->with(['invoice' => function ($q) {
            $q->select('invoiceable_id','id', 'code', 'status');}])
        ->orderBy('status', 'ASC')
        ->get();

in blade:

@foreach ($lab as $item)

{{$item->invoice->status}}
0 Answers
Related