forge/app/Livewire/User/Profile.php

55 lines
1.0 KiB
PHP
Raw Normal View History

<?php
namespace App\Livewire\User;
use App\Models\User;
use Livewire\Attributes\Url;
use Livewire\Component;
2024-09-11 09:25:02 -04:00
use Livewire\WithPagination;
class Profile extends Component
{
2024-09-11 09:25:02 -04:00
use WithPagination;
public User $user;
#[Url]
public string $section = 'wall';
public $followers;
public $following;
protected $listeners = ['refreshNeeded' => 'render'];
public function render()
{
$this->followers = $this->user->followers;
$this->following = $this->user->following;
2024-09-11 14:15:13 -04:00
$mods = $this->user->mods()->withWhereHas('latestVersion')->paginate(6);
2024-09-11 09:25:02 -04:00
return view('livewire.user.profile', compact('mods'));
}
2024-09-11 14:15:13 -04:00
public function setSection(string $name)
{
$this->section = $name;
}
public function message()
{
// todo: not implemented yet
}
public function followUser(User $user)
{
auth()->user()->follow($user);
}
public function unfollowUser(User $user)
{
auth()->user()->unfollow($user);
}
}