i am making a blog system and i am trying to include a feature where you can make posts visible and hidden. for this im trying to create a filter where i can show the hidden ones on the home page if a press a button. i have linked the checkbox to my database using this
and then linked to the postController with
$post->visible = $request->input('hide');
which stores the value in the database, seeing as it was either 1 or 0 i used the binary type in mysql now when displaying my blogposts i use this
@section('content')
<h1>Posts</h1>
<li><a href="/posts/create">Create Post</a></li>
@if(count($posts) > 1 || count($visible) == 0) //this was an attempt to fix the issue as if it's unhidden the value us 0
@foreach($posts as $post)
<div class="well">
<h3><a href= "/posts/"></a></h3>
<small> Written on</small>
</div>
<div>
<small>Expires on</small>
</div>
@endforeach
@else
<p> No posts </p>
@endif
@endsection
could you see any way around this, ideally i would have button that refreshes the results between hidden and unhidden i tried this by making a completely new if statement that runs off a button but seeing as i cannot even sort it without the button in the if statement i didn't include the code. thanks in advance and sorry for any silly mistakes in code
Aucun commentaire:
Enregistrer un commentaire