2021年3月19日星期五

Hide and Show Element in Laravel

I have a problem with the function to show and hide an element in Laravel. I don't know how to make it like when I click on the "Publish" button, it will hide the post. Furthermore, I want when I click on the "Title", it will lead me to go to the page which displays the full content of that post

This is the demonstrate

enter image description here

resources\views\livewire\posts.blade.php

@foreach($posts as $post)                  <tr>                      <td class="border px-4 py-2"></td>                      <td class="border px-4 py-2"></td>                      <td class="border px-4 py-2"></td>                      <td class="border px-4 py-2">                          <button wire:click="publish()" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Publish</button>                          <button wire:click="edit()" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Edit</button>                          <button wire:click="delete()" class="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded">Delete</button>                      </td>                  </tr>              @endforeach  

app\Http\Livewire\Posts.php

public function publish($id)  {      $post = Post::findOrFail($id);      $this->post_id = $id;      $this->title = $post->title;      $this->body = $post->body;      $this->openModal();  }  
https://stackoverflow.com/questions/66718080/hide-and-show-element-in-laravel March 20, 2021 at 11:54AM

没有评论:

发表评论