mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 12:31:23 -05:00
Add models, enums, and services for user roles, theme preferences, slug history, and ID generation
This commit is contained in:
37
app/Enums/UserRole.php
Normal file
37
app/Enums/UserRole.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum UserRole: string
|
||||
{
|
||||
case USER = 'USER';
|
||||
case MODERATOR = 'MODERATOR';
|
||||
case ADMIN = 'ADMIN';
|
||||
case SUPERUSER = 'SUPERUSER';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::USER => 'User',
|
||||
self::MODERATOR => 'Moderator',
|
||||
self::ADMIN => 'Admin',
|
||||
self::SUPERUSER => 'Superuser',
|
||||
};
|
||||
}
|
||||
|
||||
public function canModerate(): bool
|
||||
{
|
||||
return match($this) {
|
||||
self::MODERATOR, self::ADMIN, self::SUPERUSER => true,
|
||||
default => false,
|
||||
};
|
||||
}
|
||||
|
||||
public function canAdmin(): bool
|
||||
{
|
||||
return match($this) {
|
||||
self::ADMIN, self::SUPERUSER => true,
|
||||
default => false,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user