0

When I am trying to pass $enquiry[], and $society[] to a view in Laravel, I am getting this error from the view.

Property [name] does not exist on this collection instance. (View: C:\xampp\htdocs\laratheme\resources\views\assigned_enquiry_list.blade.php)

function all_assigned_enquiries()
{
    $ass_enq = DB::table('assignedenquiries')->get();
    $cat = DB::table('categories')->get();
    
    for ($i = 0; $i < count($ass_enq); $i++) {
        $ae[] = array($ass_enq[$i]->enquiry_id);
        $as[] = array($ass_enq[$i]->society_id);
        $enquiry[] = DB::table('enquiries')->where('id', '=', $ae)->get();
        $society[] = DB::table('societies')->where('id', '=', $as)->get();
    }
    
    return view('assigned_enquiry_list', ['cat' => $cat, 'enquiry' => $enquiry, 'society' => $society]);
}

enter image description here

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
  • what is the blade file look like? Also why are you doing individual get queries in foreach loop - why not run a query using whereIn() with a array of the ID's so you run a single query for all the results? – Yeak Sep 19 '22 at 22:08

1 Answers1

0

I think the error comes from your file assigned_enquiry_list.blade.php

If you are using

{{ $enquiry['your parameter'] }}

you can try it:

{{ !empty($enquiry) ? $enquiry['your parameter'] : '' }}
poppies
  • 142
  • 6