- Implemented LecturerEdit and LecturerIndex components for managing lecturers. - Created StudentCreate and StudentEdit components for adding and editing students. - Developed StudentIndex component for listing students with search and pagination. - Added department and user types for better type safety. - Updated routes for lecturers and students, including reset password functionality. - Removed AppSidebar from dashboard for a cleaner layout.
53 lines
1.4 KiB
PHP
53 lines
1.4 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\HasOne;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Spatie\Permission\Traits\HasRoles;
|
|
|
|
#[Hidden(['password'])]
|
|
#[Guarded(['id', 'last_login_at'])]
|
|
#[Appends(['full_name'])]
|
|
class User extends Authenticatable
|
|
{
|
|
use HasFactory, HasRoles, Notifiable, SoftDeletes;
|
|
|
|
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);
|
|
}
|
|
}
|