How to show followers and following lists in livewire

I am trying to use this package in livewire.
I am very interested in using livewire,But I am new to use livewire, I do not know how to do this
How to show followers and following lists in livewire
please guide me

local/user_name/followers

local/user_name/followings

If for example you have two links to access different blades or components

<a href="{{ route('user.followers', ['user_name' => Auth::user()->name]) }}">  // I use Auth::user() as example but maybe you handle different users
<a href="{{ route('user.followings', ['user_name' => Auth::user()->name]) }}">

in web.php

Route::get('/{user_name}/followers', [FollowersComponent::class])->name('users.followers');
Route::get('/{user_name}/followings', [FollowinsComponent::class])->name('users.followings');

FollowersComponent

public $followers;
public $user;

public function mount($user_name)
{
   $this->user = User::where('name', $user_name)->first();
   $this->followers = $this->user->followers();
}

public function render()
{
   return view('followers-component', ['followers' => $this->followers]);
}

and in followers-component.blade.php

@foreach($followers as $follower)
    {{ $follower->name }}
@endforeach

Let me know if you understand this way

1 Like

Thanks You for my guidance.I used your code but the following error is displayed.

ErrorException
Attempt to read property “name” on bool (View:

Hey, I doesn’t worked before with this package…I refers “name” property as an example for you. The most important I tried was show you how manage your solution. I read some over package documentation and definitely don’t retrieve data as I use here…so sorry I you misunderstood my intentions. Hope you get the idea an dev/test different solutions. Come here any issue or looking for help…all for one! jajaja

1 Like