I want to print '$post' as an array from database.
<tbody>
@if (is_array($posts) || is_object($posts)){
@foreach ($posts as $post)
<tr>
<th>{{$post->id }}</th>
<td>{{$post->title }}</td>
<td>{{$post->body }}</td>
<td>{{$post->created_at }}</td>
<td><a href="#" class="btn btn-default">View</a><a href="#" class="btn btn-default">Edit</a></td>
</tr>
@endforeach
@else
{{'no!'}}
@endif
</tbody>
it just prints no! this is the main function:
public function index()
{
$posts = Post::all();
return view('posts.index')->withPosts('$posts');
}
->withPostsa valid statement?