feat: add withdraw request functionality and UI components
This commit is contained in:
@@ -81,6 +81,33 @@ class ShiftScheduleService
|
||||
->first();
|
||||
}
|
||||
|
||||
public function nextShiftStart(User $doctor, Carbon $from): ?Carbon
|
||||
{
|
||||
$shifts = Shift::active()->where('user_id', $doctor->id)->get();
|
||||
|
||||
return $shifts
|
||||
->map(function (Shift $shift) use ($from) {
|
||||
for ($offset = 0; $offset <= 7; $offset++) {
|
||||
$day = $from->copy()->addDays($offset)->startOfDay();
|
||||
|
||||
if (!$this->coversDate($shift, $day)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$start = $day->copy()->addMinutes($this->toMinutes($shift->start_time));
|
||||
|
||||
if ($start->greaterThanOrEqualTo($from)) {
|
||||
return $start;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
})
|
||||
->filter()
|
||||
->sort()
|
||||
->first();
|
||||
}
|
||||
|
||||
public function hasConflict(array $data, ?int $ignoreId = null): bool
|
||||
{
|
||||
if (empty($data['user_id'])) {
|
||||
|
||||
Reference in New Issue
Block a user