I have a simple eloquent query:
$comments = Comment::where('approved',1)->orderBy('created_at','desc')->get();
return view('comments.approved', compact('comments'));
I am trying to access the data in view using the following syntax
@foreach($comments as $comment)
{{ $comment->content }}
@endforeach
I am getting the following error
Trying to get property of non-object (View: ...
I was able to resolve the problem by either of these
{{ @$comment->content }}
or
{{ $comment['content'] }}
However, I fail to understand why get() is returning an array instead of collection. Isn't get() suppose to return collection of objects?