Reputation: 872
my query is something like this..
$query = DB::table('categories')
->select('categories.name','category_company.id as catcompid ','category_company.company_id','category_company.category_id')
->leftJoin('category_company', function($leftJoin){
$leftJoin->on('categories.id', '=', 'category_company.category_id');
})
->groupBy('categories.name')
->get();
and my view is like this..
@foreach($top as $tp)
<tr>
<td>{{ $tp->name }}</td>
<td>
{{ $tp->catcompid }}
</td>
</tr>
@endforeach
it is giving me error like this
ErrorException in 7a50b25fc86bfddf956cb4108a130dd2 line 42: Undefined property: stdClass::$catcompid (View: /var/www/test/resources/views/top/index.blade.php)
the view is not recognizing catcompid why?
Upvotes: 1
Views: 50
Reputation: 1048
Your query seems to right, what I suggest you can check 1) if you have joined on right query. 2) check if you had correctly mentioned
groupBy('categories.name')
condition. let me know, if you need further assistance.
Upvotes: 1