mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-10 05:42:58 +00:00
This commit is contained in:
parent
21e59d775a
commit
f60ae41bf6
26 changed files with 741 additions and 70 deletions
46
app/Livewire/App/Role.php
Normal file
46
app/Livewire/App/Role.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\App;
|
||||
|
||||
use App\Enums\RolesEnum;
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
|
||||
class Role extends Component
|
||||
{
|
||||
public User $user;
|
||||
public string $size = 'small';
|
||||
protected string $variant = 'neutral';
|
||||
protected string $name = '';
|
||||
|
||||
public function mount(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
if ($user->hasRole(RolesEnum::RESTRICTED))
|
||||
{
|
||||
$this->variant = RolesEnum::RESTRICTED->variant();
|
||||
$this->name = RolesEnum::RESTRICTED->label();
|
||||
}
|
||||
if ($user->hasRole(RolesEnum::MEMBER))
|
||||
{
|
||||
$this->variant = RolesEnum::MEMBER->variant();
|
||||
$this->name = RolesEnum::MEMBER->label();
|
||||
}
|
||||
if ($user->hasRole(RolesEnum::MODERATOR))
|
||||
{
|
||||
$this->variant = RolesEnum::MODERATOR->variant();
|
||||
$this->name = RolesEnum::MODERATOR->label();
|
||||
}
|
||||
if ($user->hasRole(RolesEnum::ADMIN))
|
||||
{
|
||||
$this->variant = RolesEnum::ADMIN->variant();
|
||||
$this->name = RolesEnum::ADMIN->label();
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.app.role');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue