How to get Where paramete in Alpinejs

There is a list of posts and two button to get the authors of posts as:
$posts = from laravel function => $posts = Post::all();
Post model has 2 columns : name, author.

<div x-data={ posts: {{ $posts }} }>

<button @click=" ... show the posts where author is A">A Authors</button> 
<button @clik="... show posts where author is B">B Authors</button>

<template x-for='(post, index) in posts' :key='index'>
<div>
<h3 x-text="post.name"></h3>
<p x-text="post.author"></p>
</div>
</template>
</div>

How I can click on A Authors and B Authors and get the author where A or B?

hey @mehdiyaq, your question is not understandable.
if you mean by your question “How can I get authors depends on their posts” you can make a relationship “Belongs to the user” in Post model and eager load it in $posts = Post::with('user')->get() and get the posts depends on the author’s id.

or

you can do it like so

in User Model

public function posts() {
  return  $this->hasMany(Post::class)
}

in view

<button wire:click="showPostsByAuthor({{$authorID}})"> X Author</button>

in controller or livewire Component

public function showPostsByAuthor(User $user)
{
   $posts = $user->posts()->get();
 // ...
}