in below code i have Eloquent command and that return Collection object and i can not fetch that into view.
$collection = DB::table('contents')
->join('categories', function($join)
{
$join->on('categories.id', '=', 'contents.category');
})
->where('contents.id', '=', $id)
->get();
thats return single Collecton Object and i do not need to use foreach
.
how to fetch this collection object in view without usign foreach
?
i get error after using this :
echo $collection->title;
{{ $collection->title }}
ERROR:
Trying to get property of non-object