new to Laravel, and just having this problem that I couldn't figure it out.
I have a post controller set up to query out all blog posts. On the database, I have a integer column and named as "status", 0 as inactive, 1 as active. The question is how and where to place the logic to check whetherthe status is 0 or 1, and show "inactive" or "active" in the view. Thanks in advance.
public function index()
{
$posts = Post::where('user_id', 1)->orderBy('id', 'desc')->paginate(5);
return view('post.index')->withPosts($posts);
}
Here is the view
<table class="table">
<tr>
<th>Date Created</th>
<th>Title</th>
<th>Status</th>
</tr>
@foreach ($posts as $post)
<tr>
<td></td>
<td><a href="/posts/"></a></td>
<td></td>
</tr>
<br>
@endforeach
</table>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire