Some checks failed
tests / ci (pull_request) Has been cancelled
- Moved profile and security settings from the general settings route to a dedicated admin settings route. - Created new components and pages for managing user profile and security settings. - Updated user menu to link to the new admin settings pages. - Removed old settings pages and routes that are no longer in use. - Added tests for profile and security settings functionality.
66 lines
1.8 KiB
PHP
66 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Appends;
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
|
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Fortify\TwoFactorAuthenticatable;
|
|
use Laravel\Passkeys\PasskeyAuthenticatable;
|
|
use Spatie\Permission\Traits\HasRoles;
|
|
|
|
#[Hidden(['password'])]
|
|
#[Guarded(['id', 'last_login_at'])]
|
|
#[Appends(['full_name'])]
|
|
class User extends Authenticatable
|
|
{
|
|
use HasFactory, HasRoles, Notifiable, PasskeyAuthenticatable, SoftDeletes, TwoFactorAuthenticatable;
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_active' => 'boolean',
|
|
'last_login_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
'two_factor_confirmed_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
protected function fullName(): Attribute
|
|
{
|
|
return Attribute::get(fn () => $this->profile?->full_name ?? $this->username);
|
|
}
|
|
|
|
public function profile(): HasOne
|
|
{
|
|
return $this->hasOne(UserProfile::class);
|
|
}
|
|
|
|
public function student(): HasOne
|
|
{
|
|
return $this->hasOne(Student::class);
|
|
}
|
|
|
|
public function lecturer(): HasOne
|
|
{
|
|
return $this->hasOne(Lecturer::class);
|
|
}
|
|
|
|
public function notifications(): HasMany
|
|
{
|
|
return $this->hasMany(Notification::class);
|
|
}
|
|
|
|
public function feedbacks(): HasMany
|
|
{
|
|
return $this->hasMany(Feedback::class);
|
|
}
|
|
}
|