mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
53 lines
1.0 KiB
PHP
53 lines
1.0 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Livewire\User;
|
||
|
|
||
|
use Illuminate\View\View;
|
||
|
use Livewire\Attributes\Locked;
|
||
|
use Livewire\Component;
|
||
|
|
||
|
class FollowButtons extends Component
|
||
|
{
|
||
|
/**
|
||
|
* The ID of the user whose profile is being viewed.
|
||
|
*/
|
||
|
#[Locked]
|
||
|
public int $profileUserId;
|
||
|
|
||
|
/**
|
||
|
* Whether the authenticated user is currently following the profile user.
|
||
|
*/
|
||
|
#[Locked]
|
||
|
public bool $isFollowing;
|
||
|
|
||
|
/**
|
||
|
* Action to follow a user.
|
||
|
*/
|
||
|
public function follow(): void
|
||
|
{
|
||
|
auth()->user()->follow($this->profileUserId);
|
||
|
$this->isFollowing = true;
|
||
|
|
||
|
$this->dispatch('user-follow-change');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Action to unfollow a user.
|
||
|
*/
|
||
|
public function unfollow(): void
|
||
|
{
|
||
|
auth()->user()->unfollow($this->profileUserId);
|
||
|
$this->isFollowing = false;
|
||
|
|
||
|
$this->dispatch('user-follow-change');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Render the component.
|
||
|
*/
|
||
|
public function render(): View
|
||
|
{
|
||
|
return view('livewire.user.follow-buttons');
|
||
|
}
|
||
|
}
|