Below is my ShowPost
component and I’d like the Title
attribute to be dynamic depending on the post title
instead of hard coding 'Laravel Roadmap'
. Passing 'title' => $post->title
in the blade template it doesn’t work too. How can I make this dynamic?
<?php
namespace AppLivewirePosts;
use AppModelsPost;
use LivewireAttributesTitle;
use LivewireComponent;
class ShowPost extends Component
{
public $post;
public function mount(Post $post)
{
$this->post = $post;
}
#[Title('Laravel Roadmap')]
public function render()
{
return view('livewire.posts.show-post', [
'post' => $this->post,
]);
}
}