Add user roles system

This commit is contained in:
2026-01-16 23:14:47 +01:00
parent c0be2e294a
commit e5ef197ed6
21 changed files with 206 additions and 85 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Livewire;
use App\Enums\UserRole;
use App\Models\Comment;
use App\Models\User;
@@ -17,7 +18,7 @@ class AdminUserSearch extends Component
public $search = '';
#[Url(history: true)]
public $filtered = ['true'];
public $discordId = '';
#[Url(history: true)]
public $patreon = [];
@@ -38,10 +39,10 @@ class AdminUserSearch extends Component
public function render()
{
$users = User::when($this->filtered !== [], fn ($query) => $query->where('id', '>=', 10000))
->when($this->patreon !== [], fn ($query) => $query->where('is_patreon', 1))
->when($this->banned !== [], fn ($query) => $query->where('is_banned', 1))
$users = User::when($this->patreon !== [], fn ($query) => $query->whereJsonContains('roles', UserRole::SUPPORTER->value))
->when($this->banned !== [], fn ($query) => $query->whereJsonContains('roles', UserRole::BANNED->value))
->when($this->search !== '', fn ($query) => $query->where('name', 'like', '%'.$this->search.'%'))
->when($this->discordId !== '', fn ($query) => $query->where('discord_id', '=', $this->discordId))
->paginate(20);
return view('livewire.admin-user-search', [