Deploy Ladill Care / deploy (push) Successful in 1m0s
Phase 3 staff management: real shift entities, week roster linked to temporary assignments, and a nursing ops module surface (registry, today’s allocation, unit shortcuts). Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
||
|
||
namespace App\Models;
|
||
|
||
use App\Models\Concerns\BelongsToOwner;
|
||
use Illuminate\Database\Eloquent\Model;
|
||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||
|
||
class Shift extends Model
|
||
{
|
||
use BelongsToOwner, SoftDeletes;
|
||
|
||
protected $table = 'care_shifts';
|
||
|
||
protected $fillable = [
|
||
'owner_ref',
|
||
'organization_id',
|
||
'code',
|
||
'label',
|
||
'start_time',
|
||
'end_time',
|
||
'color',
|
||
'sort_order',
|
||
'is_active',
|
||
];
|
||
|
||
protected function casts(): array
|
||
{
|
||
return [
|
||
'is_active' => 'boolean',
|
||
'sort_order' => 'integer',
|
||
];
|
||
}
|
||
|
||
public function organization(): BelongsTo
|
||
{
|
||
return $this->belongsTo(Organization::class, 'organization_id');
|
||
}
|
||
|
||
public function rosterEntries(): HasMany
|
||
{
|
||
return $this->hasMany(RosterEntry::class, 'shift_id');
|
||
}
|
||
|
||
public function timeLabel(): string
|
||
{
|
||
$start = substr((string) $this->start_time, 0, 5);
|
||
$end = substr((string) $this->end_time, 0, 5);
|
||
|
||
return $start.'–'.$end;
|
||
}
|
||
}
|