users menu listing

This commit is contained in:
Mark Gregory
2026-08-26 08:01:49 +01:00
parent 6f8d0c7abf
commit 7dc31371f6
29 changed files with 779 additions and 669 deletions
+10
View File
@@ -2,6 +2,8 @@
namespace App\Livewire\Settings;
use Illuminate\Contracts\View\View;
use Livewire\Attributes\Layout;
use Livewire\Attributes\Title;
use Livewire\Component;
@@ -9,4 +11,12 @@ use Livewire\Component;
class Appearance extends Component
{
//
#[Layout('layouts.app')]
public function render(): View
{
return view()->file(
resource_path('themes/backend/views/livewire/settings/appearance.blade.php')
);
}
}
+8
View File
@@ -2,6 +2,7 @@
namespace App\Livewire\Settings;
use Illuminate\Contracts\View\View;
use App\Concerns\PasswordValidationRules;
use App\Livewire\Actions\Logout;
use Illuminate\Support\Facades\Auth;
@@ -26,4 +27,11 @@ class DeleteUserForm extends Component
$this->redirect('/', navigate: true);
}
public function render(): View
{
return view()->file(
resource_path('themes/backend/views/livewire/settings/delete-user-form.blade.php')
);
}
}
+10
View File
@@ -2,10 +2,12 @@
namespace App\Livewire\Settings;
use Illuminate\Contracts\View\View;
use App\Concerns\ProfileValidationRules;
use Flux\Flux;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\Layout;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Title;
use Livewire\Component;
@@ -81,4 +83,12 @@ class Profile extends Component
return ! $user instanceof MustVerifyEmail || $user->hasVerifiedEmail();
}
#[Layout('layouts.app')]
public function render(): View
{
return view()->file(
resource_path('themes/backend/views/livewire/settings/profile.blade.php')
);
}
}
+10
View File
@@ -2,6 +2,7 @@
namespace App\Livewire\Settings;
use Illuminate\Contracts\View\View;
use App\Concerns\PasswordValidationRules;
use Exception;
use Flux\Flux;
@@ -13,6 +14,7 @@ use Laravel\Fortify\Actions\EnableTwoFactorAuthentication;
use Laravel\Fortify\Features;
use Laravel\Fortify\Fortify;
use Laravel\Passkeys\Actions\DeletePasskey;
use Livewire\Attributes\Layout;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Locked;
use Livewire\Attributes\Title;
@@ -309,4 +311,12 @@ class Security extends Component
'buttonText' => __('Continue'),
];
}
#[Layout('layouts.app')]
public function render(): View
{
return view()->file(
resource_path('themes/backend/views/livewire/settings/security.blade.php')
);
}
}
@@ -2,6 +2,7 @@
namespace App\Livewire\Settings\TwoFactor;
use Illuminate\Contracts\View\View;
use Exception;
use Laravel\Fortify\Actions\GenerateNewRecoveryCodes;
use Livewire\Attributes\Locked;
@@ -48,4 +49,11 @@ class RecoveryCodes extends Component
}
}
}
public function render(): View
{
return view()->file(
resource_path('themes/backend/views/livewire/settings/two-factor/recovery-codes.blade.php')
);
}
}
+24 -38
View File
@@ -2,7 +2,6 @@
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
@@ -14,33 +13,22 @@ use Illuminate\Support\Str;
use Laravel\Fortify\Contracts\PasskeyUser;
use Laravel\Fortify\PasskeyAuthenticatable;
use Laravel\Fortify\TwoFactorAuthenticatable;
use Modules\Helpdesk\Concerns\HasHelpdeskTickets;
/**
* @property int $id
* @property string $name
* @property string $email
* @property Carbon|null $email_verified_at
* @property string $password
* @property string|null $two_factor_secret
* @property string|null $two_factor_recovery_codes
* @property Carbon|null $two_factor_confirmed_at
* @property string|null $remember_token
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property bool $helpdesk_agent
* @property bool $helpdesk_admin
*/
#[Fillable(['name', 'email', 'password'])]
#[Fillable(['name', 'email', 'password', 'email_verified_at', 'helpdesk_agent', 'helpdesk_admin'])]
#[Hidden(['password', 'two_factor_secret', 'two_factor_recovery_codes', 'remember_token'])]
class User extends Authenticatable implements PasskeyUser
{
/** @use HasFactory<UserFactory> */
use HasFactory, HasHelpdeskTickets, Notifiable, PasskeyAuthenticatable, TwoFactorAuthenticatable;
use HasFactory, Notifiable, PasskeyAuthenticatable, TwoFactorAuthenticatable;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
@@ -51,28 +39,6 @@ class User extends Authenticatable implements PasskeyUser
];
}
/**
* Backwards-compatible application-level admin check.
*
* Helpdesk currently owns the admin role, so this maps to the
* Helpdesk admin permission flag.
*/
public function isAdmin(): bool
{
return $this->isHelpdeskAdmin();
}
/**
* Backwards-compatible application-level agent check.
*/
public function isAgent(): bool
{
return $this->isHelpdeskAgent();
}
/**
* Get the user's initials
*/
public function initials(): string
{
$initials = Str::initials($this->name, true);
@@ -81,4 +47,24 @@ class User extends Authenticatable implements PasskeyUser
? Str::substr($initials, 0, 1).Str::substr($initials, -1)
: $initials;
}
public function isHelpdeskAdmin(): bool
{
return (bool) $this->helpdesk_admin;
}
public function isHelpdeskAgent(): bool
{
return $this->isHelpdeskAdmin() || (bool) $this->helpdesk_agent;
}
public function isAdmin(): bool
{
return $this->isHelpdeskAdmin();
}
public function isAgent(): bool
{
return $this->isHelpdeskAgent();
}
}