generated from theradcoza/Laravel-Docker-Dev-Template
- Add shifts, shift_staff, and shift_attendance migrations - Add Shift, ShiftStaff, ShiftAttendance Eloquent models with auditing - Add ShiftService with business logic (create, start, complete, assign staff, mark attendance, reports, timesheets) - Add ShiftResource with list, create, edit, and attendance management pages - Add staff and attendance relation managers - Add standalone pages: ActiveShifts, StaffManagement, ShiftReports, Timesheets - Add dashboard widgets: ShiftOverview stats, TodaysShifts table - Add ShiftPolicy for role-based authorization - Add 10 shift permissions and manager role to RolePermissionSeeder - Update User model with shift relationships - Fix audits table migration with required columns for owen-it/laravel-auditing - Update DatabaseSeeder to create admin user and call RolePermissionSeeder - Switch docker-compose to MariaDB 10.11 for Docker Desktop compatibility
72 lines
1.6 KiB
PHP
72 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
use Spatie\Permission\Traits\HasRoles;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
/** @use HasFactory<\Database\Factories\UserFactory> */
|
|
use HasFactory, Notifiable, HasRoles, HasApiTokens;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'password',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
];
|
|
}
|
|
|
|
// --- Shift Relationships ---
|
|
|
|
public function shifts(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Shift::class, 'shift_staff')
|
|
->withPivot('assigned_by')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function shiftAttendances(): HasMany
|
|
{
|
|
return $this->hasMany(ShiftAttendance::class);
|
|
}
|
|
|
|
public function createdShifts(): HasMany
|
|
{
|
|
return $this->hasMany(Shift::class, 'created_by');
|
|
}
|
|
}
|