repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Livewire/Locations/DefaultRestingTimesManager.php
app/Http/Livewire/Locations/DefaultRestingTimesManager.php
<?php namespace App\Http\Livewire\Locations; use Livewire\Component; use Brick\Math\BigDecimal; use App\Contracts\AddsDefaultRestingTime; use App\Contracts\RemovesDefaultRestingTime; class DefaultRestingTimesManager extends Component { /** * The location instance. * * @var mixed */ public $location; public $addDefaultRestingTimeModal = false; public $defaultRestingTimeForm = [ 'min_hours' => null, 'duration' => null ]; public $defaultRestingTimeIdBeingRemoved = null; public $confirmingDefaultRestingTimeRemoval = false; /** * Mount the component. * * @param mixed $location * @return void */ public function mount($location) { $this->location = $location; } public function confirmDefaultRestingTimeRemoval($defaultRestingTimeId) { $this->confirmingDefaultRestingTimeRemoval = true; $this->defaultRestingTimeIdBeingRemoved = $defaultRestingTimeId; } public function addDefaultRestingTime(AddsDefaultRestingTime $adder) { $adder->add($this->location, [ 'min_hours' => BigDecimal::of($this->defaultRestingTimeForm['min_hours'])->multipliedBy(3600), 'duration' => BigDecimal::of($this->defaultRestingTimeForm['duration'])->multipliedBy(60) ]); $this->location = $this->location->fresh(); $this->emit('savedDefaultRestingTime'); $this->addDefaultRestingTimeModal = false; } /** * Remove a default resting time from the location. * * @param \App\Actions\RemovesDefaultRestingTime $remover * @return void */ public function removePublicHoliday(RemovesDefaultRestingTime $remover) { $remover->remove( $this->location, $this->defaultRestingTimeIdBeingRemoved ); $this->confirmingDefaultRestingTimeRemoval = false; $this->defaultRestingTimeIdBeingRemoved = null; $this->location = $this->location->fresh(); } public function openDefaultRestingTimeModal() { $this->addDefaultRestingTimeModal = true; } public function closeDefaultRestingTimeModal() { $this->reset('defaultRestingTimeForm'); $this->addDefaultRestingTimeModal = false; } public function render() { return view('locations.default-resting-times-manager', [ 'defaultRestingTimes' => $this->location->defaultRestingTimes()->paginate(10) ] ); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Livewire/Employee/Report.php
app/Http/Livewire/Employee/Report.php
<?php namespace App\Http\Livewire\Employee; use Carbon\Carbon; use App\Models\User; use Livewire\Component; use App\Models\Location; use App\Formatter\DateFormatter; use App\Contracts\FiltersEvaluation; class Report extends Component { /** * Holds the employee instance */ public $employee; /** * Holds the location instance */ public $location; protected $listeners = [ 'changedDateFilter' => 'filterReport', 'changedEmployee' => 'filterReport' ]; public $dateFilter = [ 'fromDate' => null, 'toDate' => null, ]; public $employeeSwitcher; public $employeeIdToBeSwitched = null; protected $report; public function report() { return $this->report; } public function mount(User $employee, DateFormatter $dateFormatter) { $this->employee = $employee; $this->location = $employee->currentLocation; $this->employeeSwitcher = $employee->currentLocation->allUsers()->pluck('name','id')->toArray(); $this->dateFilter = [ 'fromDate' => $employee->date_of_employment->gt(Carbon::now()->startOfMonth()) ? $dateFormatter->formatDateForView($employee->date_of_employment) : $dateFormatter->formatDateForView(Carbon::now()->startOfMonth()), 'toDate' => $dateFormatter->formatDateForView(Carbon::now()->endOfMonth()) ]; $this->filterReport(app(FiltersEvaluation::class)); } public function switchEmployee() { $this->employee = $this->location->allUsers()->first(function ($user) { return $user->id === (int)$this->employeeIdToBeSwitched; }); $this->emit('changedEmployee'); } public function filterUntilToday(DateFormatter $dateFormatter) { $this->dateFilter['toDate'] = $dateFormatter->formatDateForView(Carbon::now()->endOfDay()); $this->emit('changedDateFilter'); } public function filterReport(FiltersEvaluation $evaluation) { $this->resetErrorBag(); $this->report = $evaluation->filter( $this->employee, $this->location, $this->dateFilter ); } public function render() { return view('livewire.employee.report'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Livewire/Absence/AbsenceManager.php
app/Http/Livewire/Absence/AbsenceManager.php
<?php namespace App\Http\Livewire\Absence; use Carbon\Carbon; use Livewire\Component; use Carbon\CarbonPeriod; use App\Models\AbsenceType; use Livewire\WithPagination; use App\Contracts\AddsAbsences; use App\Formatter\DateFormatter; use App\Contracts\RemovesAbsence; use App\Contracts\ApprovesAbsence; use App\AbsenceCalendar\AbsenceCalculator; use App\AbsenceCalendar\EmployeeAbsenceCalendar; use App\Traits\HasUser; class AbsenceManager extends Component { use WithPagination, HasUser; public $absenceModal = false; public $confirmingAbsenceRemoval = false; public $absenceIdBeingRemoved = null; public $hours; public $minutes; /** * The user that is currently having its absence managed. * * @var mixed */ public $managingAbsenceForId; public $startDate; public $startHours = 9; public $startMinutes = 0; public $endDate; public $endHours = 17; public $endMinutes = 0; public $hideTime = true; public $hideDetails = true; public $addAbsenceForm = [ 'absence_type_id' => null, 'full_day' => true ]; public $absenceTypes; public $vacationInfoPanel = [ 'overall_vacation_days' => 0, 'used_days' => 0, 'transferred_days' => 0, 'available_days' => 0 ]; public $vacationInfoPanelUntil = [ 'until' => null, 'overall_vacation_days' => 0, 'used_days' => 0, 'transferred_days' => 0, 'available_days' => 0 ]; public $vacationDays; public $paidHours; protected $calculatedDays = []; public $employeeFilter = []; public $employeeSimpleSelectOptions; public $employeeMultipleSelectOptions; public function updated() { //TODO set to start of day and end of day if full day is activated... $calendar = new EmployeeAbsenceCalendar( $this->user, $this->user->currentLocation, new CarbonPeriod( $this->startTimeStr(), $this->endTimeStr() ) ); $calculator = new AbsenceCalculator($calendar, AbsenceType::findOrFail($this->addAbsenceForm['absence_type_id'])); $this->calculatedDays = $calculator->getDays(); $this->vacationDays = (string) $calculator->sumVacationDays(); $this->paidHours = (string) $calculator->sumPaidHours(); } public function refreshAbsenceHours() { //TODO set to start of day and end of day if full day is activated... $calendar = new EmployeeAbsenceCalendar( $this->user, $this->user->currentLocation, new CarbonPeriod( $this->startTimeStr(), $this->endTimeStr() ) ); $calculator = new AbsenceCalculator($calendar, AbsenceType::findOrFail($this->addAbsenceForm['absence_type_id'])); $this->calculatedDays = $calculator->getDays(); $this->vacationDays = $calculator->sumVacationDays(); $this->paidHours = $calculator->sumPaidHours(); } public function mount(DateFormatter $dateFormatter) { $this->absenceTypes = $this->user->absenceTypesForLocation($this->user->currentLocation); $this->hours = range(0,23); $this->minutes = range(0,59); $employeeSelectCollection = $this->user->currentLocation->allUsers()->pluck('name', 'id'); $this->employeeSimpleSelectOptions = $employeeSelectCollection->toArray(); $this->employeeMultipleSelectOptions = $employeeSelectCollection->mapToMultipleSelect(); $this->managingAbsenceForId = (string)$this->user->id; $this->resetFormFields(); $this->buildVacationInfoPanel($this->user, $dateFormatter); } protected function buildVacationInfoPanel($employee, $dateFormatter) { if ($employee->hasVacationEntitlement()) { $this->vacationInfoPanel = array_merge($this->vacationInfoPanel, [ 'overall_vacation_days' => $employee->overallVacationDays(), 'used_days' => $employee->usedVacationDays(), 'transferred_days' => $employee->transferredDays(), 'available_days' => $employee->availableVacationDays() ]); $latestVacationEntitlement = $employee->latestVacationEntitlement(); if ($latestVacationEntitlement) { $this->vacationInfoPanelUntil = array_merge($this->vacationInfoPanelUntil, [ 'until' => $dateFormatter->formatDateForView($latestVacationEntitlement->ends_at), 'overall_vacation_days' => $employee->overallVacationDays($latestVacationEntitlement->ends_at, true), 'used_days' => $employee->usedVacationDays($latestVacationEntitlement->ends_at), 'available_days' => $employee->availableVacationDays($latestVacationEntitlement->ends_at, true) ]); } } } public function openAbsenceModal() { $this->absenceModal = true; } public function closeAbsenceModal() { $this->absenceModal = false; } public function startTimeStr() { return app(DateFormatter::class)->generateTimeStr( $this->startDate, $this->startHours, $this->startMinutes ); } public function endTimeStr() { return app(DateFormatter::class)->generateTimeStr( $this->endDate, $this->endHours, $this->endMinutes ); } public function addAbsence(AddsAbsences $adder) { $this->clearValidation(); $this->addAbsenceForm = array_merge($this->addAbsenceForm, [ 'starts_at' => $this->startTimeStr(), 'ends_at' => $this->endTimeStr(), 'full_day' => $this->hideTime ]); $adder->add( $this->user, $this->user->currentLocation, $this->managingAbsenceForId, $this->addAbsenceForm ); $this->resetFormfields(); $this->user = $this->user->fresh(); $this->absenceModal = false; } protected function resetFormFields() { $this->startDate = $this->endDate = app(DateFormatter::class) ->formatDateForView(Carbon::today()); $this->addAbsenceForm['absence_type_id'] = $this->absenceTypes->keys()->first(); } public function approveAbsence($absenceId, ApprovesAbsence $approver) { if (!empty($absenceId)) { $approver->approve( $this->user, $this->user->currentLocation, $absenceId ); } $this->user = $this->user->fresh(); } public function confirmAbsenceRemoval($absenceId) { $this->confirmingAbsenceRemoval = true; $this->absenceIdBeingRemoved = $absenceId; } public function removeAbsence(RemovesAbsence $remover) { $remover->remove( $this->user, $this->user->currentLocation, $this->absenceIdBeingRemoved ); $this->confirmingAbsenceRemoval = false; $this->absenceIdBeingRemoved = null; } public function render() { return view('absences.absence-manager', [ 'calculatedDays' => $this->calculatedDays, 'absences' => $this->user->currentLocation ->absences() ->orderBy('status','DESC') ->latest() ->when( $this->user->hasLocationPermission($this->user->currentLocation, 'filterAbsences'), fn($query) => $query->filterEmployees( collect($this->employeeFilter)->pluck('id')->toArray() ), fn($query) => $query->filterEmployees([$this->user->id]) ) ->paginate(10) ]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Livewire/TimeTracking/PauseTimes.php
app/Http/Livewire/TimeTracking/PauseTimes.php
<?php namespace App\Http\Livewire\TimeTracking; use Livewire\Component; class PauseTimes extends Component { public $pause; public $index; public $hours; public $minutes; public function mount(array $pause, int $index) { $this->pause = $pause; $this->index = $index; $this->hours = range(0,23); $this->minutes = range(0,59); } public function render() { return view('time_trackings.pause-times'); } public function changedTime() { $this->emitUp( 'changedTime', $this->pause, $this->index ); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Livewire/TimeTracking/TimeTrackingManager.php
app/Http/Livewire/TimeTracking/TimeTrackingManager.php
<?php namespace App\Http\Livewire\TimeTracking; use App\Daybreak; use Carbon\Carbon; use App\Models\User; use App\Traits\HasUser; use Livewire\Component; use Illuminate\Support\Arr; use Livewire\WithPagination; use App\Formatter\DateFormatter; use App\Contracts\AddsTimeTrackings; use App\Contracts\RemovesTimeTracking; use App\Contracts\UpdatesTimeTracking; use App\Http\Livewire\TrimAndNullEmptyStrings; use Daybreak\Project\Contracts\AddsTimeTrackingWithProjectInfo; use Daybreak\Project\Contracts\UpdatesTimeTrackingWithProjectInfo; class TimeTrackingManager extends Component { use WithPagination, TrimAndNullEmptyStrings, HasUser; /** * Indicates if the application is currently adding or editin time trackings * * @var bool */ public $manageTimeTracking = false; /** * Indicates if the application is confirming if a time tracking should be removed. * * @var bool */ public $confirmingTimeTrackingRemoval = false; /** * The ID of the time tracking being removed. * * @var int|null */ public $timeTrackingIdBeingRemoved = null; public $timeTrackingIdBeingUpdated = null; protected $listeners = ['changedTime' => 'updatePause']; public $hours; public $minutes; public $workingSession; public $timeTrackingForm = [ 'description' => null, 'date' => null, 'start_hour' => 9, 'start_minute' => 0, 'end_hour' => 17, 'end_minute' => 0, ]; public $pauseTimeForm = []; public $employeeFilter; public $employeeSimpleSelectOptions; public $employeeMultipleSelectOptions; public $managingTimeTrackingForId; public function mount(DateFormatter $dateFormatter) { $employeeSelectCollection = $this->user->currentLocation->allUsers()->pluck('name', 'id'); $this->employeeSimpleSelectOptions = $employeeSelectCollection->toArray(); $this->employeeMultipleSelectOptions = $employeeSelectCollection->mapToMultipleSelect(); $this->employeeFilter = collect($this->employeeMultipleSelectOptions) ->filterMultipleSelect(fn($item) => $item['id'] === $this->user->id); $this->timeTrackingForm = array_merge_when(array_merge($this->timeTrackingForm, [ 'date' => $dateFormatter->formatDateTimeForView(Carbon::today()) ]), fn() => $this->projectFormFields(), Daybreak::hasProjectBillingFeature()); $this->managingTimeTrackingForId = (string)$this->user->id; $this->hours = range(0, 23); $this->minutes = range(0, 59); $this->workingSession = $this->user->currentWorkingSession(); } protected function generatePauseTimeArray($date, array $pauseTimes, DateFormatter $dateFormatter) { return array_map(function ($pause) use ($date, $dateFormatter) { return [ 'starts_at' => $dateFormatter->generateTimeStr( $date, $pause['start_hour'], $pause['start_minute'] ), 'ends_at' => $dateFormatter->generateTimeStr( $date, $pause['end_hour'], $pause['end_minute'] ) ]; }, $pauseTimes, []); } public function confirmAddTimeTracking(DateFormatter $dateFormatter) { $this->resetErrorBag(); $generatedPauseTimeArray = $this->generatePauseTimeArray( $this->timeTrackingForm['date'], $this->pauseTimeForm, $dateFormatter ); if (Daybreak::hasProjectBillingFeature()) { app(AddsTimeTrackingWithProjectInfo::class)->add( $this->user, $this->user->currentLocation, $this->managingTimeTrackingForId, array_merge([ 'starts_at' => $dateFormatter->generateTimeStr( $this->timeTrackingForm['date'], $this->timeTrackingForm['start_hour'], $this->timeTrackingForm['start_minute'] ), 'ends_at' => $dateFormatter->generateTimeStr( $this->timeTrackingForm['date'], $this->timeTrackingForm['end_hour'], $this->timeTrackingForm['end_minute'] ), ], $this->filteredTimeTrackingFormFields()), $generatedPauseTimeArray ); } else { app(AddsTimeTrackings::class)->add( $this->user, $this->user->currentLocation, $this->managingTimeTrackingForId, array_merge([ 'starts_at' => $dateFormatter->generateTimeStr( $this->timeTrackingForm['date'], $this->timeTrackingForm['start_hour'], $this->timeTrackingForm['start_minute'] ), 'ends_at' => $dateFormatter->generateTimeStr( $this->timeTrackingForm['date'], $this->timeTrackingForm['end_hour'], $this->timeTrackingForm['end_minute'] ), ], $this->filteredTimeTrackingFormFields()), $generatedPauseTimeArray ); } $this->user = $this->user->fresh(); $this->manageTimeTracking = false; } public function render() { return view('time_trackings.time-tracking-manager', [ 'timing' => $this->user->currentLocation ->timeTrackings() ->latest() ->when( $this->user->hasLocationPermission($this->user->currentLocation, 'filterAbsences'), fn($query) => $query->filterEmployees( collect($this->employeeFilter)->pluck('id')->toArray() ), fn($query) => $query->filterEmployees([$this->user->id]) ) ->paginate(10) ]); } public function addPauseTime() { $this->pauseTimeForm[] = [ 'start_hour' => 12, 'start_minute' => 00, 'end_hour' => 12, 'end_minute' => 30 ]; } public function removePause($index) { unset($this->pauseTimeForm[$index]); } public function updatePause($pause, $index) { $this->pauseTimeForm[$index] = $pause; } public function confirmTimeTrackingRemoval($timeTrackingId) { $this->confirmingTimeTrackingRemoval = true; $this->timeTrackingIdBeingRemoved = $timeTrackingId; } /** * Remove a time tracking from the employee. * * @param \App\Contracts\RemovesTimeTracking $remover * @return void */ public function removeTimeTracking(RemovesTimeTracking $remover) { $remover->remove( $this->user, $this->timeTrackingIdBeingRemoved ); $this->confirmingTimeTrackingRemoval = false; $this->timeTrackingIdBeingRemoved = null; $this->user = $this->user->fresh(); } public function manageTimeTracking() { $this->manageTimeTracking = true; } public function updatedManageTimeTracking($managing) { if (!$managing) { $this->cancelManagingTimeTracking(); } } public function cancelManagingTimeTracking() { $this->reset([ 'managingTimeTrackingForId', 'manageTimeTracking', 'timeTrackingIdBeingUpdated', 'timeTrackingForm', 'pauseTimeForm' ]); } public function updateTimeTracking($index) { $this->timeTrackingIdBeingUpdated = $index; $this->updateTimeTrackingForm( $this->user->currentLocation->timeTrackings() ->whereKey($index) ->with('pauseTimes') ->first() ); $this->manageTimeTracking = true; } public function updateTimeTrackingForm($timeTracking) { $this->managingTimeTrackingForId = $timeTracking->user_id; $this->timeTrackingForm = array_merge_when(array_merge($this->timeTrackingForm,[ 'date' => app(DateFormatter::class)->formatDateForView($timeTracking->starts_at), 'start_hour' => $timeTracking->starts_at->hour, 'start_minute' => $timeTracking->starts_at->minute, 'end_hour' => $timeTracking->ends_at->hour, 'end_minute' => $timeTracking->ends_at->minute, 'description' => $timeTracking->description ]), fn() => $this->updateProjectFormFields($timeTracking), Daybreak::hasProjectBillingFeature()); $this->pauseTimeForm = []; $timeTracking->pauseTimes->each(function ($pauseTime) { $this->pauseTimeForm[] = [ 'start_hour' => $pauseTime->starts_at->hour, 'start_minute' => $pauseTime->starts_at->minute, 'end_hour' => $pauseTime->ends_at->hour, 'end_minute' => $pauseTime->ends_at->minute ]; }); } public function confirmUpdateTimeTracking(DateFormatter $dateFormatter) { $this->resetErrorBag(); $generatedPauseTimeArray = $this->generatePauseTimeArray( $this->timeTrackingForm['date'], $this->pauseTimeForm, $dateFormatter ); if (Daybreak::hasProjectBillingFeature()) { app(UpdatesTimeTrackingWithProjectInfo::class)->update( $this->user, $this->user->currentLocation, $this->managingTimeTrackingForId, $this->timeTrackingIdBeingUpdated, array_merge([ 'starts_at' => $dateFormatter->generateTimeStr( $this->timeTrackingForm['date'], $this->timeTrackingForm['start_hour'], $this->timeTrackingForm['start_minute'] ), 'ends_at' => $dateFormatter->generateTimeStr( $this->timeTrackingForm['date'], $this->timeTrackingForm['end_hour'], $this->timeTrackingForm['end_minute'] ), ], $this->filteredTimeTrackingFormFields()), $generatedPauseTimeArray ); } else { app(UpdatesTimeTracking::class)->update( $this->user, $this->user->currentLocation, $this->managingTimeTrackingForId, $this->timeTrackingIdBeingUpdated, array_merge([ 'starts_at' => $dateFormatter->generateTimeStr( $this->timeTrackingForm['date'], $this->timeTrackingForm['start_hour'], $this->timeTrackingForm['start_minute'] ), 'ends_at' => $dateFormatter->generateTimeStr( $this->timeTrackingForm['date'], $this->timeTrackingForm['end_hour'], $this->timeTrackingForm['end_minute'] ), ], $this->filteredTimeTrackingFormFields()), $generatedPauseTimeArray ); } $this->reset([ 'managingTimeTrackingForId', 'manageTimeTracking', 'timeTrackingIdBeingUpdated', 'timeTrackingForm', 'pauseTimeForm' ]); } public function transition($to) { $state = $this->workingSession->status->resolveStateClass($to); if (!is_null($state) && $this->workingSession->status->canTransitionTo($state)) { $this->workingSession->status->transitionTo($state); } $this->workingSession = $this->workingSession->fresh(); } private function filteredTimeTrackingFormFields() { return Arr::except($this->timeTrackingForm, ['date', 'start_hour', 'start_minute', 'end_hour', 'end_minute']); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Livewire/Employees/EditUserProfile.php
app/Http/Livewire/Employees/EditUserProfile.php
<?php namespace App\Http\Livewire\Employees; use App\Daybreak; use App\Models\User; use Livewire\Component; use Brick\Math\BigDecimal; use App\Formatter\DateFormatter; use App\Contracts\AddsTargetHours; use App\Contracts\RemovesTargetHour; use App\Contracts\UpdatesEmployeeProfile; use App\Contracts\AddsVacationEntitlements; use App\Contracts\RemovesVacationEntitlements; use Illuminate\Validation\ValidationException; use App\Contracts\TransfersVacationEntitlements; use Brick\Math\Exception\DivisionByZeroException; use Brick\Math\Exception\RoundingNecessaryException; use Daybreak\Payroll\Contracts\UpdatesEmployeeProfileWithPayrollId; class EditUserProfile extends Component { /** * Indicates if the application is confirming if a target hours should be removed. * * @var bool */ public $confirmingTargetHourRemoval = false; /** * The ID of the target hours being removed. * * @var int|null */ public $targetHourIdBeingRemoved = null; /** * Holds the employee profile */ public $employee; public $currentlyManagingTargetHours = false; public $currentlyManagingVacationEntitlement = false; public $targetHourForm = [ 'start_date' => null, 'hours_per' => 'week', 'target_hours' => 40, 'target_limited' => false, ]; public $vacationEntitlementForm = [ 'name' => '', 'starts_at' => null, 'ends_at' => null, 'days' => null, 'expires' => true, 'transfer_remaining' => false, 'end_of_transfer_period' => null ]; public $editUserProfileForm = [ 'name' => null, 'date_of_employment' => null, 'opening_overtime_balance' => null, 'is_account_admin' => false ]; public $days = [ 'mon' => [ 'state' => true, 'hours' => 8 ], 'tue' => [ 'state' => true, 'hours' => 8 ], 'wed' => [ 'state' => true, 'hours' => 8 ], 'thu' => [ 'state' => true, 'hours' => 8 ], 'fri' => [ 'state' => true, 'hours' => 8 ], 'sat' => [ 'state' => false, 'hours' => 0 ], 'sun' => [ 'state' => false, 'hours' => 0 ], ]; public $availbleDays; public $vacationEntitlementIdBeingRemoved = null; public $confirmingVacationEntitlementRemoval = false; public function confirmVactationEntitlementRemoval($vacationEntitlementIdBeingRemoved) { $this->vacationEntitlementIdBeingRemoved = $vacationEntitlementIdBeingRemoved; $this->confirmingVacationEntitlementRemoval = true; } public function removeVacationEntitlement(RemovesVacationEntitlements $remover) { $remover->remove($this->employee, $this->vacationEntitlementIdBeingRemoved); $this->confirmingVacationEntitlementRemoval = false; $this->vacationEntitlementIdBeingRemoved = null; $this->employee = $this->employee->fresh(); $this->emit('removedVacationEntitlement'); } public function transferVacationEntitlement($vacationEntitlementId, TransfersVacationEntitlements $transferrer) { $transferrer->transfer( $this->employee, $vacationEntitlementId ); $this->employee = $this->employee->fresh(); } public function setHoursPerMode(string $mode) { $this->resetErrorBag(); $this->targetHourForm['hours_per'] = $mode; switch ($mode) { case 'month': foreach ($this->days as $key => &$day) { $day['hours'] = 0; } break; default: $this->updateDailyHours(); break; } } public function changeTargetHours(string $value) { $this->resetErrorBag(); if (isset($this->targetHourForm['target_hours']) && BigDecimal::of($this->targetHourForm['target_hours'])->isEqualTo($value) ) { return; } // set current value $this->targetHourForm['target_hours'] = $value; if ($this->targetHourForm['hours_per'] == 'month') { return; } $this->updateDailyHours(); } protected function updateDailyHours() { $this->availbleDays = collect($this->days)->filter(function ($days) { return $days['state'] == true; }); try { $hoursPerDay = BigDecimal::of($this->targetHourForm['target_hours']) ->dividedBy($this->availbleDays->count(), 2); } catch (DivisionByZeroException $ex) { throw ValidationException::withMessages([ 'days' => [ __('Please mark at least one day as active.') ], ])->errorBag('addTargetHour'); } catch (RoundingNecessaryException $ex) { throw ValidationException::withMessages([ 'target_hours' => [ __('Rounding error occured. Please select another value.') ], ])->errorBag('addTargetHour'); } foreach ($this->availbleDays as $key => $day) { $this->days[$key]['hours'] = $hoursPerDay; } } public function toggleDayState(string $day) { $this->days[$day]['state'] = $this->days[$day]['state'] ? false : true; if (!$this->days[$day]['state']) { $this->days[$day]['hours'] = 0; } if ($this->targetHourForm['hours_per'] == 'month') { return; } $this->updateDailyHours(); } public function toggleTargetLimited() { $this->targetHourForm['target_limited'] = $this->targetHourForm['target_limited'] ? false : true; } public function mount(User $employee) { $this->employee = $employee; $this->editUserProfileForm = array_merge_when([ 'name' => $this->employee->name, 'date_of_employment' => $this->employee->date_of_employment_for_humans, 'opening_overtime_balance' => $this->employee->opening_overtime_balance, 'is_account_admin' => $this->employee->is_account_admin ], fn() => $this->fillPayrollFormFields($employee), Daybreak::hasEmployeePayrollFeature()); } public function manageTargetHour() { $this->currentlyManagingTargetHours = true; } public function stopManageTargetHour() { $this->currentlyManagingTargetHours = false; } public function saveTargetHour(AddsTargetHours $adder) { $this->resetErrorBag(); $adder->add( $this->employee, array_merge( $this->targetHourForm, $this->flattenDays($this->days) ), $this->availbleDays ); $this->employee = $this->employee->fresh(); $this->currentlyManagingTargetHours = false; $this->emit('savedTargetHours'); } public function saveEmployeeProfile() { $this->resetErrorBag(); if (Daybreak::hasEmployeePayrollFeature()) { app(UpdatesEmployeeProfileWithPayrollId::class)->update( $this->employee, $this->editUserProfileForm ); } else { app(UpdatesEmployeeProfile::class)->update( $this->employee, $this->editUserProfileForm ); } $this->employee = $this->employee->fresh(); $this->emit('savedProfile'); } protected function flattenDays($days): array { return collect($days)->map(function ($value, $key) { return [ 'is_'.$key => $value['state'], $key => $value['hours'] ]; })->mapWithKeys(function ($flatten) { return $flatten; })->toArray(); } public function confirmTargetHourRemoval($targetHourId) { $this->confirmingTargetHourRemoval = true; $this->targetHourIdBeingRemoved = $targetHourId; } /** * Remove target hours from the employee. * * @param \App\Contracts\RemovesTargetHour $remover * @return void */ public function removeTargetHour(RemovesTargetHour $remover) { $remover->remove( $this->employee, $this->targetHourIdBeingRemoved ); $this->confirmingTargetHourRemoval = false; $this->targetHourIdBeingRemoved = null; $this->employee = $this->employee->fresh(); $this->emit('removedTargetHours'); } public function manageVacationEntitlement() { $this->vacationEntitlementForm = array_merge($this->vacationEntitlementForm, [ 'starts_at' => app(DateFormatter::class)->formatDateForView(now()->startOfYear()), 'ends_at' => app(DateFormatter::class)->formatDateForView(now()->endOfYear()) ]); $this->currentlyManagingVacationEntitlement = true; } public function stopManagingVacationEntitlement() { $this->currentlyManagingVacationEntitlement = false; } public function saveVacationEntitlement(AddsVacationEntitlements $adder) { $this->resetErrorBag(); $adder->add( $this->employee, $this->vacationEntitlementForm ); $this->employee = $this->employee->fresh(); $this->currentlyManagingVacationEntitlement = false; $this->emit('savedVacationEntitlement'); } public function render() { return view('livewire.employees.edit-user-profile'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Livewire/Accounts/EditAccountMasterData.php
app/Http/Livewire/Accounts/EditAccountMasterData.php
<?php namespace App\Http\Livewire\Accounts; use App\Models\Account; use Livewire\Component; use Illuminate\Support\Facades\Validator; class EditAccountMasterData extends Component { /** * The account instance * * @var Account */ public $account; /** * The update Account form * * @var array */ public $updateAccountForm = [ 'name' => '' ]; public function mount($account) { $this->account = $account; $this->updateAccountForm['name'] = $account->name; } public function updateAccountSettings() { $this->resetErrorBag(); Validator::make([ 'name' => $this->updateAccountForm['name'], ], [ 'name' => ['required', 'string', 'max:255'], ])->validateWithBag('updateAccount'); $this->account->forceFill([ 'name' => $this->updateAccountForm['name'] ])->save(); $this->emit('updated'); } public function render() { return view('livewire.accounts.edit-account-master-data'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Livewire/Accounts/ShowEmployeesForAccount.php
app/Http/Livewire/Accounts/ShowEmployeesForAccount.php
<?php namespace App\Http\Livewire\Accounts; use App\Models\Account; use Livewire\Component; class ShowEmployeesForAccount extends Component { /** * Holds the account instance */ public $account; public function mount(Account $account) { $this->account = $account; } public function render() { return view('livewire.accounts.show-employees-for-account'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/TimeTrackingController.php
app/Http/Controllers/TimeTrackingController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class TimeTrackingController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { return view('time_trackings.index'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/AbsenceTypeController.php
app/Http/Controllers/AbsenceTypeController.php
<?php namespace App\Http\Controllers; use App\Models\AbsenceType; use Illuminate\Http\Request; class AbsenceTypeController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } /** * Display the specified resource. * * @param \App\Models\AbsenceType $absenceType * @return \Illuminate\Http\Response */ public function show(AbsenceType $absenceType) { // } /** * Show the form for editing the specified resource. * * @param \App\Models\AbsenceType $absenceType * @return \Illuminate\Http\Response */ public function edit(AbsenceType $absenceType) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\AbsenceType $absenceType * @return \Illuminate\Http\Response */ public function update(Request $request, AbsenceType $absenceType) { // } /** * Remove the specified resource from storage. * * @param \App\Models\AbsenceType $absenceType * @return \Illuminate\Http\Response */ public function destroy(AbsenceType $absenceType) { // } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/VacationBanController.php
app/Http/Controllers/VacationBanController.php
<?php namespace App\Http\Controllers; use App\Models\VacationBan; use Illuminate\Http\Request; class VacationBanController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } /** * Display the specified resource. * * @param \App\Models\VacationBan $vacationBan * @return \Illuminate\Http\Response */ public function show(VacationBan $vacationBan) { // } /** * Show the form for editing the specified resource. * * @param \App\Models\VacationBan $vacationBan * @return \Illuminate\Http\Response */ public function edit(VacationBan $vacationBan) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\VacationBan $vacationBan * @return \Illuminate\Http\Response */ public function update(Request $request, VacationBan $vacationBan) { // } /** * Remove the specified resource from storage. * * @param \App\Models\VacationBan $vacationBan * @return \Illuminate\Http\Response */ public function destroy(VacationBan $vacationBan) { // } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/CurrentLocationController.php
app/Http/Controllers/CurrentLocationController.php
<?php namespace App\Http\Controllers; use App\Daybreak; use Illuminate\Http\Request; class CurrentLocationController extends Controller { /** * Update the authenticated user's current location. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse */ public function update(Request $request) { $location = Daybreak::newLocationModel()->findOrFail($request->location_id); if (! $request->user()->switchLocation($location)) { abort(403); } return redirect(config('fortify.home'), 303); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/ShowEmployeesForAccountController.php
app/Http/Controllers/ShowEmployeesForAccountController.php
<?php namespace App\Http\Controllers; use App\Models\Account; use Illuminate\Support\Facades\Gate; class ShowEmployeesForAccountController extends Controller { public function __invoke(Account $account) { if (Gate::denies('view', $account)) { abort(403); } return view('employees.index', compact('account')); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/AccountController.php
app/Http/Controllers/AccountController.php
<?php namespace App\Http\Controllers; use App\Models\Account; use Illuminate\Http\Request; use Illuminate\Support\Facades\Gate; class AccountController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } /** * Display the specified resource. * * @param \App\Models\Account $account * @return \Illuminate\Http\Response */ public function show(Account $account) { if (Gate::denies('view', $account)) { abort(403); } return view('accounts.show',compact('account')); } /** * Show the form for editing the specified resource. * * @param \App\Models\Account $account * @return \Illuminate\Http\Response */ public function edit(Account $account) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\Account $account * @return \Illuminate\Http\Response */ public function update(Request $request, Account $account) { // } /** * Remove the specified resource from storage. * * @param \App\Models\Account $account * @return \Illuminate\Http\Response */ public function destroy(Account $account) { // } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/Controller.php
app/Http/Controllers/Controller.php
<?php namespace App\Http\Controllers; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/PublicHolidayController.php
app/Http/Controllers/PublicHolidayController.php
<?php namespace App\Http\Controllers; use App\Models\PublicHoliday; use Illuminate\Http\Request; class PublicHolidayController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } /** * Display the specified resource. * * @param \App\Models\PublicHoliday $publicHoliday * @return \Illuminate\Http\Response */ public function show(PublicHoliday $publicHoliday) { // } /** * Show the form for editing the specified resource. * * @param \App\Models\PublicHoliday $publicHoliday * @return \Illuminate\Http\Response */ public function edit(PublicHoliday $publicHoliday) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\PublicHoliday $publicHoliday * @return \Illuminate\Http\Response */ public function update(Request $request, PublicHoliday $publicHoliday) { // } /** * Remove the specified resource from storage. * * @param \App\Models\PublicHoliday $publicHoliday * @return \Illuminate\Http\Response */ public function destroy(PublicHoliday $publicHoliday) { // } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/EditEmployeeController.php
app/Http/Controllers/EditEmployeeController.php
<?php namespace App\Http\Controllers; use App\Models\User; use App\Models\Account; use Illuminate\Support\Facades\Gate; class EditEmployeeController extends Controller { public function __invoke(Account $account, User $employee) { if (Gate::denies('view', $account)) { abort(403); } return view('employees.edit',['employee' => $employee]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/ReportController.php
app/Http/Controllers/ReportController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class ReportController extends Controller { public function __invoke(Request $request) { return view('reports.show', [ 'employee' => $request->user() ]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/LocationSettingsController.php
app/Http/Controllers/LocationSettingsController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Gate; class LocationSettingsController extends Controller { /** * Display the specified resource. * * @param \App\Models\Location $location * @return \Illuminate\Http\Response */ public function show(Request $request) { if (Gate::denies('view', $request->user()->currentLocation)) { abort(403); } return view('locations.show', [ 'user' => $request->user() ]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/ShowLocationsForAccountController.php
app/Http/Controllers/ShowLocationsForAccountController.php
<?php namespace App\Http\Controllers; use App\Models\Account; use Illuminate\Http\Request; use Illuminate\Support\Facades\Gate; class ShowLocationsForAccountController extends Controller { public function __invoke(Account $account, Request $request) { if (Gate::denies('view', $account)) { abort(403); } return view('locations.index', [ 'account' => $account, 'user' => $request->user() ]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/LocationInvitationController.php
app/Http/Controllers/LocationInvitationController.php
<?php namespace App\Http\Controllers; use App\Contracts\AddsLocationMembers; use Illuminate\Http\Request; use App\Models\LocationInvitation; class LocationInvitationController extends Controller { public function accept(Request $request, LocationInvitation $invitation, AddsLocationMembers $addsLocationMembers) { $addsLocationMembers->add( $invitation->location->owner, $invitation->location, $invitation->email, $invitation->role ); $invitation->delete(); return redirect(config('fortify.home'))->banner( __('Great! You have accepted the invitation to join the :location team.', ['location' => $invitation->location->name]), ); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/LocationCalendarController.php
app/Http/Controllers/LocationCalendarController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class LocationCalendarController extends Controller { public function show(Request $request) { return view('calendars.show', [ 'employee' => $request->user() ]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Controllers/AbsenceController.php
app/Http/Controllers/AbsenceController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class AbsenceController extends Controller { public function __invoke(Request $request) { return view('absences.index'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Middleware/EnsureUserHasCurrentLocation.php
app/Http/Middleware/EnsureUserHasCurrentLocation.php
<?php namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Route; use App\Providers\RouteServiceProvider; use Illuminate\Support\Facades\Redirect; use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\SessionGuard; use Illuminate\Contracts\Auth\Factory as AuthFactory; class EnsureUserHasCurrentLocation { /** * The authentication factory implementation. * * @var \Illuminate\Contracts\Auth\Factory */ protected $auth; /** * Create a new middleware instance. * * @param \Illuminate\Contracts\Auth\Factory $auth * @return void */ public function __construct(AuthFactory $auth) { $this->auth = $auth; } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) { if (Auth::check() && !$request->user()->currentLocation()->exists()) { Auth::logout(); $request->session()->flush(); $request->session()->regenerate(); throw new AuthenticationException( 'Unauthenticated.', [Auth::getDefaultDriver()], RouteServiceProvider::HOME ); } return $next($request); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Middleware/Authenticate.php
app/Http/Middleware/Authenticate.php
<?php namespace App\Http\Middleware; use Illuminate\Auth\Middleware\Authenticate as Middleware; class Authenticate extends Middleware { /** * Get the path the user should be redirected to when they are not authenticated. * * @param \Illuminate\Http\Request $request * @return string|null */ protected function redirectTo($request) { if (! $request->expectsJson()) { return route('login'); } } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Middleware/RedirectIfAuthenticated.php
app/Http/Middleware/RedirectIfAuthenticated.php
<?php namespace App\Http\Middleware; use App\Providers\RouteServiceProvider; use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; class RedirectIfAuthenticated { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null ...$guards * @return mixed */ public function handle(Request $request, Closure $next, ...$guards) { $guards = empty($guards) ? [null] : $guards; foreach ($guards as $guard) { if (Auth::guard($guard)->check()) { return redirect(RouteServiceProvider::HOME); } } return $next($request); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Middleware/TrustProxies.php
app/Http/Middleware/TrustProxies.php
<?php namespace App\Http\Middleware; use Fideloper\Proxy\TrustProxies as Middleware; use Illuminate\Http\Request; class TrustProxies extends Middleware { /** * The trusted proxies for this application. * * @var array|string|null */ protected $proxies = '*'; /** * The headers that should be used to detect proxies. * * @var int */ protected $headers = Request::HEADER_X_FORWARDED_ALL; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Middleware/PreventRequestsDuringMaintenance.php
app/Http/Middleware/PreventRequestsDuringMaintenance.php
<?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware; class PreventRequestsDuringMaintenance extends Middleware { /** * The URIs that should be reachable while maintenance mode is enabled. * * @var array */ protected $except = [ // ]; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Middleware/TrimStrings.php
app/Http/Middleware/TrimStrings.php
<?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware; class TrimStrings extends Middleware { /** * The names of the attributes that should not be trimmed. * * @var array */ protected $except = [ 'password', 'password_confirmation', ]; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Middleware/TrustHosts.php
app/Http/Middleware/TrustHosts.php
<?php namespace App\Http\Middleware; use Illuminate\Http\Middleware\TrustHosts as Middleware; class TrustHosts extends Middleware { /** * Get the host patterns that should be trusted. * * @return array */ public function hosts() { return [ $this->allSubdomainsOfApplicationUrl(), ]; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Middleware/EncryptCookies.php
app/Http/Middleware/EncryptCookies.php
<?php namespace App\Http\Middleware; use Illuminate\Cookie\Middleware\EncryptCookies as Middleware; class EncryptCookies extends Middleware { /** * The names of the cookies that should not be encrypted. * * @var array */ protected $except = [ // ]; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Http/Middleware/VerifyCsrfToken.php
app/Http/Middleware/VerifyCsrfToken.php
<?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; class VerifyCsrfToken extends Middleware { /** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ // ]; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Mail/AbsenceRemoved.php
app/Mail/AbsenceRemoved.php
<?php namespace App\Mail; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; class AbsenceRemoved extends Mailable { use Queueable, SerializesModels; /** * Build the message. * * @return $this */ public function build() { return $this->subject(__("Absence Removed")) ->markdown('mail.absence-removed'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Mail/AbsenceStatusApproved.php
app/Mail/AbsenceStatusApproved.php
<?php namespace App\Mail; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; class AbsenceStatusApproved extends Mailable { use Queueable, SerializesModels; protected $user; protected $absence; /** * Create a new message instance. * * @return void */ public function __construct($user, $absence) { $this->absence = $absence; $this->user = $user; } /** * Build the message. * * @return $this */ public function build() { return $this->subject(__("Absence Status Changed.")) ->markdown('mail.absence-approved', [ 'employee' => $this->user, 'absence' => $this->absence ]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Mail/NewAbsenceWaitingForApproval.php
app/Mail/NewAbsenceWaitingForApproval.php
<?php namespace App\Mail; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; class NewAbsenceWaitingForApproval extends Mailable { use Queueable, SerializesModels; protected $absence; protected $employee; /** * Create a new message instance. * * @return void */ public function __construct($absence, $employee) { $this->absence = $absence; $this->employee = $employee; } /** * Build the message. * * @return $this */ public function build() { return $this->subject(__("New absence waiting for approval")) ->markdown('mail.absence-waiting-for-approval',[ 'employee' => $this->employee, 'absence' => $this->absence ]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Mail/LocationInvitation.php
app/Mail/LocationInvitation.php
<?php namespace App\Mail; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Support\Facades\URL; use Illuminate\Queue\SerializesModels; use App\Models\LocationInvitation as LocationInvitationModel; use Illuminate\Contracts\Queue\ShouldQueue; class LocationInvitation extends Mailable implements ShouldQueue { use Queueable, SerializesModels; /** * The team invitation instance. * * @var \App\Models\LocationInvitationModel */ public $invitation; /** * Create a new message instance. * * @param \App\Models\LocationInvitationModel $invitation * @return void */ public function __construct(LocationInvitationModel $invitation) { $this->invitation = $invitation; } /** * Build the message. * * @return $this */ public function build() { return $this->markdown('mail.location-invitation', ['acceptUrl' => URL::signedRoute('location-invitations.accept', [ 'invitation' => $this->invitation, ])]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Casts/BigDecimalCast.php
app/Casts/BigDecimalCast.php
<?php namespace App\Casts; use Brick\Math\BigDecimal; use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use PHPUnit\Framework\MockObject\UnknownTypeException; class BigDecimalCast implements CastsAttributes { /** * Cast the given value. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key * @param mixed $value * @param array $attributes * @return mixed */ public function get($model, $key, $value, $attributes) { if (!$value) { return BigDecimal::zero(); } return BigDecimal::of($value); } /** * Prepare the given value for storage. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key * @param mixed $value * @param array $attributes * @return mixed */ public function set($model, $key, $value, $attributes) { if ($value instanceof BigDecimal || is_string($value)) { return $value; } if (is_float($value) || is_integer($value)) { return (string) $value; } throw new UnknownTypeException("Value has wrong type"); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Casts/DurationCast.php
app/Casts/DurationCast.php
<?php namespace App\Casts; use App\Models\Duration; use Brick\Math\BigDecimal; use PHPUnit\Framework\MockObject\UnknownTypeException; use Illuminate\Contracts\Database\Eloquent\CastsAttributes; class DurationCast implements CastsAttributes { /** * Cast the given value. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key * @param mixed $value * @param array $attributes * @return mixed */ public function get($model, $key, $value, $attributes) { if (!$value) { return new Duration(0); } return new Duration($value); } /** * Prepare the given value for storage. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key * @param mixed $value * @param array $attributes * @return mixed */ public function set($model, $key, $value, $attributes) { if ($value instanceof BigDecimal || is_string($value)) { return $value; } if ($value instanceof Duration) { return $value->inSeconds(); } throw new UnknownTypeException("Value should be of type BigDecimal or Duration"); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Casts/WeekDayCast.php
app/Casts/WeekDayCast.php
<?php namespace App\Casts; use App\Models\Day; use Brick\Math\BigDecimal; use App\Collections\WeekDayCollection; use PHPUnit\Framework\MockObject\UnknownTypeException; use Illuminate\Contracts\Database\Eloquent\CastsAttributes; class WeekDayCast implements CastsAttributes { /** * Cast the given value. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key * @param mixed $value * @param array $attributes * @return mixed */ public function get($model, $key, $value, $attributes) { $collection = new WeekDayCollection(); $collection->map( function ($day) use ($attributes) { if (!isset($attributes[$day->day])) { return; } $day->hours = BigDecimal::of($attributes[$day->day]); $day->state = $attributes['is_'.$day->day]; return $day; } ); return $collection; } /** * Prepare the given value for storage. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key * @param mixed $value * @param array $attributes * @return mixed */ public function set($model, $key, $value, $attributes) { if ($value instanceof WeekDayCollection) { return $value->serializeForDatabase(); } throw new UnknownTypeException("Value should be WeekDayCollection"); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Traits/HasPeriod.php
app/Traits/HasPeriod.php
<?php namespace App\Traits; use Carbon\CarbonInterval; use Carbon\CarbonPeriod; trait HasPeriod { public function getPeriodAttribute() { return new CarbonPeriod( $this->starts_at, CarbonInterval::minutes(1), $this->ends_at ); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Traits/HasUser.php
app/Traits/HasUser.php
<?php namespace App\Traits; use Illuminate\Support\Facades\Auth; trait HasUser { /** * Get the current user of the application. * * @return mixed */ public function getUserProperty() { return Auth::user(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Traits/HasLocations.php
app/Traits/HasLocations.php
<?php namespace App\Traits; use App\Daybreak; use App\Models\Location; use Illuminate\Support\Str; use Laravel\Jetstream\Jetstream; use Laravel\Jetstream\OwnerRole; use Laravel\Sanctum\HasApiTokens; trait HasLocations { public function ownedLocations() { return $this->hasMany(Daybreak::locationModel(), 'owned_by'); } public function ownsLocation($location) { if (!$location) { return false; } return $this->id == $location->owned_by; } /** * Determine if the given location is the current location. * * @param mixed $location * @return bool */ public function isCurrentLocation($location) { return $location->id === $this->currentLocation->id; } /** * Get the current location of the user's context. */ public function currentLocation() { return $this->belongsTo(Daybreak::locationModel(), 'current_location_id'); } /** * Switch the user's context to the given location. * * @return bool */ public function switchLocation(Location $location) { if (! $this->belongsToLocation($location)) { return false; } $this->forceFill([ 'current_location_id' => $location->id, ])->save(); $this->setRelation('currentLocation', $location); return true; } /** * Get all of the locations the user owns or belongs to. * * @return \Illuminate\Collections\Collection */ public function allLocations() { return $this->ownedLocations->merge($this->locations)->sortBy('name'); } /** * Get all of the locations the user belongs to. */ public function locations() { return $this->belongsToMany(Daybreak::locationModel(), Daybreak::membershipModel()) ->withPivot('role') ->withTimestamps() ->as('membership'); } /** * Determine if the user belongs to the given location. * * @param mixed $location * @return bool */ public function belongsToLocation($location) { return $this->locations->contains(function ($l) use ($location) { return $l->id === $location->id; }) || $this->ownsLocation($location); } /** * Get the role that the user has on the location. * * @param mixed $location * @return \Laravel\Jetstream\Role */ public function locationRole($location) { if ($this->ownslocation($location)) { return new OwnerRole; } if (! $this->belongsToLocation($location)) { return; } return Jetstream::findRole($location->users->where( 'id', $this->id )->first()->membership->role); } /** * Determine if the user has the given role on the given location. * * @param mixed $location * @param string $role * @return bool */ public function hasLocationRole($location, string $role) { if ($this->ownsLocation($location)) { return true; } return $this->belongsToLocation($location) && optional(Jetstream::findRole($location->users->where( 'id', $this->id )->first()->membership->role))->key === $role; } /** * Get the user's permissions for the given location. * * @param mixed $location * @return array */ public function locationPermissions($location) { if ($this->ownsLocation($location)) { return ['*']; } if (! $this->belongsToLocation($location)) { return []; } return $this->locationRole($location)->permissions; } /** * Determine if the user has the given permission on the given location. * * @param mixed $location * @param string $permission * @return bool */ public function hasLocationPermission($location, string $permission) { if ($this->ownslocation($location)) { return true; } if (! $this->belongsTolocation($location)) { return false; } if (in_array(HasApiTokens::class, class_uses_recursive($this)) && ! $this->tokenCan($permission) && $this->currentAccessToken() !== null) { return false; } $permissions = $this->locationPermissions($location); return in_array($permission, $permissions) || in_array('*', $permissions) || (Str::endsWith($permission, ':create') && in_array('*:create', $permissions)) || (Str::endsWith($permission, ':update') && in_array('*:update', $permissions)); } public function isLocationAdmin($location) { return $this->hasLocationRole($location, 'admin'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Traits/HasVacations.php
app/Traits/HasVacations.php
<?php namespace App\Traits; use DateTime; use Brick\Math\BigDecimal; use App\Models\VacationEntitlement; trait HasVacations { public function hasVacationEntitlement() { return $this->vacationEntitlements()->exists(); } public function vacationEntitlements() { return $this->hasMany(VacationEntitlement::class); } public function availableVacationEntitlements() { return $this->vacationEntitlements() ->notUsed() ->notExpired(); } public function currentVacationEntitlement() { $today = now()->startOfDay(); return $this->availableVacationEntitlements() ->where('ends_at','>=',$today) ->orderBy('ends_at','ASC') ->get() ->first(); } public function latestVacationEntitlement() { return $this->availableVacationEntitlements() ->orderBy('ends_at','DESC') ->limit(1) ->first(); } /** * Overal entitled vacation days, except transferred days * * @param DateTime $until * @param boolean $excludeExpired * @return BigDecimal */ public function overallVacationDays(DateTime $until = null, $excludeExpired = false) { return once(function () use ($until, $excludeExpired) { return $this->vacationEntitlements() ->when($excludeExpired, function ($query) { $query->whereNotIn('status', ['expired']); }) ->when(isset($until), function ($query) use ($until) { $query->where('ends_at', '<=', $until); })->get()->sumBigDecimals('available_days'); }); } public function transferredDays() { return once(function () { return $this->vacationEntitlements ->sumBigDecimals('transfer_days'); }); } public function usedVacationDays(DateTime $until = null) { return once(function () use ($until) { return $this->vacationEntitlements() ->when(isset($until), function ($query) use ($until) { $query->where('ends_at', '<=',$until); })->get()->sumBigDecimals('used_days'); }); } public function availableVacationDays($endsAt = null, $excludeExpired = false) { return $this->overallVacationDays($endsAt, $excludeExpired) ->minus($this->usedVacationDays()); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Traits/HasAccounts.php
app/Traits/HasAccounts.php
<?php namespace App\Traits; use App\Models\Account; trait HasAccounts { public function account() { return $this->belongsTo(Account::class); } public function ownedAccount() { return $this->hasOne(Account::class, 'owned_by'); } public function ownsAccount(Account $account) { return $this->id == $account->owned_by; } public function isAccountAdmin(Account $account) { return $this->ownsAccount($account) || ($this->belongsToAccount($account) && $this->is_account_admin); } /** * Switch the user's context to the given account. * * @return bool */ public function switchAccount(Account $account) { if (! $this->belongsToAccount($account)) { return false; } $this->forceFill([ 'account_id' => $account->id, ])->save(); $this->setRelation('account', $account); return true; } /** * Determine if the user belongs to the given account. * * @param mixed $account * @return bool */ public function belongsToAccount($account) { return $this->locations->contains(function ($l) use ($account) { return $l->id === $account->id; }) || $this->ownsAccount($account); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Traits/HasTargetHours.php
app/Traits/HasTargetHours.php
<?php namespace App\Traits; use Carbon\Carbon; use App\Models\TargetHour; trait HasTargetHours { public function targetHours() { return $this->hasMany(TargetHour::class); } public function getTargetHour($date) : TargetHour { return once(function () use ($date) { return $this->targetHours()->where('start_date', function ($query) use ($date) { return $query->select('start_date') ->from('target_hours') ->where('start_date','<=',$date) ->where('user_id', $this->id) ->orderBy('start_date','DESC') ->groupBy('start_date') ->limit(1); })->orderBy('start_date','ASC')->firstOrNew([]); }); } public function targetHourDayForDate(Carbon $date) { return $this->getTargetHour($date) ->week_days ->getDayForDate($date); } public function targetHoursForDate(Carbon $date) { return $this->targetHourDayForDate($date)->hours; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Traits/FiltersEmployees.php
app/Traits/FiltersEmployees.php
<?php namespace App\Traits; trait FiltersEmployees { public function scopeFilterEmployees($query, array $filtered) { if (empty($filtered)) { return $query; } return $query->whereIn('user_id', $filtered); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Traits/HasTimeTrackings.php
app/Traits/HasTimeTrackings.php
<?php namespace App\Traits; use App\Models\Location; use App\Models\TimeTracking; trait HasTimeTrackings { public function timeTrackings() { return $this->hasMany(TimeTracking::class); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Traits/HasAbsences.php
app/Traits/HasAbsences.php
<?php namespace App\Traits; use App\Models\Absence; use App\Models\Location; use App\Models\AbsenceType; use App\Models\AbsenceIndex; use App\Models\AbsenceTypeUser; trait HasAbsences { public function absences() { return $this->hasMany(Absence::class); } public function absenceTypes() { return $this->belongsToMany(AbsenceType::class, AbsenceTypeUser::class) ->withTimestamps() ->as('absenceTypes'); } public function absenceIndex() { return $this->hasMany(AbsenceIndex::class); } public function absenceTypesForLocation(Location $location) { return $this->absenceTypes->filter(function (AbsenceType $absenceType) use ($location) { return $absenceType->location_id === $location->id; })->pluck('title','id'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Traits/HasDefaultRestingTimes.php
app/Traits/HasDefaultRestingTimes.php
<?php namespace App\Traits; use App\Models\DefaultRestingTime; use App\Models\DefaultRestingTimeUser; trait HasDefaultRestingTimes { public function defaultRestingTimes() { return $this->belongsToMany(DefaultRestingTime::class, DefaultRestingTimeUser::class) ->withTimestamps() ->orderBy('min_hours','DESC') ->as('defaultRestingTimes'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Traits/HasEvaluation.php
app/Traits/HasEvaluation.php
<?php namespace App\Traits; use App\Models\TargetHour; use App\Models\TimeTracking; use Brick\Math\BigDecimal; trait HasEvaluation { public function workingHoursForDate($date) { $working_hours = $this->timeTrackings() ->whereDate('starts_at',$date) ->get(); return $working_hours->reduce(function (BigDecimal $total, TimeTracking $timeTracking) { return $total->plus($timeTracking->balance); }, BigDecimal::zero()); } public function absentHoursForDate($date) { return $this->absenceIndex()->where('date',$date); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/AbsenceCalendar/AbsenceCalendar.php
app/AbsenceCalendar/AbsenceCalendar.php
<?php namespace App\AbsenceCalendar; interface AbsenceCalendar { public function getWorkingDays(); public function getVacationDays(); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/AbsenceCalendar/AbsenceCalculator.php
app/AbsenceCalendar/AbsenceCalculator.php
<?php namespace App\AbsenceCalendar; use App\Models\AbsenceType; use Brick\Math\BigDecimal; class AbsenceCalculator { public $calendar; public $absenceType; public function __construct(AbsenceCalendar $calendar, AbsenceType $absenceType) { $this->calendar = $calendar; $this->absenceType = $absenceType; } public function sumVacationDays() { return $this->absenceType->affectsVacation() ? $this->calendar->getVacationDays()->sumBigDecimals( fn($day) => $day->getVacation() ) : BigDecimal::zero(); } /** * Paid hours are only calculated if it actually affects the evaluation and * it should be equaled out with target hours. * * @return BigDecimal */ public function sumPaidHours() { return $this->absenceType->affectsEvaluation() && $this->absenceType->shouldSumAbsenceHoursUpToTargetHours() ? $this->calendar->getWorkingDays()->sumBigDecimals( fn($day) => $day->getPaidHours() ) : BigDecimal::zero(); } public function getDays() { return $this->calendar->days; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/AbsenceCalendar/EmployeeAbsenceCalendarDay.php
app/AbsenceCalendar/EmployeeAbsenceCalendarDay.php
<?php namespace App\AbsenceCalendar; use App\Formatter\DateFormatter; use Closure; use Carbon\Carbon; use App\Models\Day; use Brick\Math\BigDecimal; use Illuminate\Contracts\Support\Arrayable; class EmployeeAbsenceCalendarDay implements AbsenceCalendarDay, Arrayable { protected $date; protected $day; protected $state; protected $targetHours; protected $vacation; protected $isPublicHoliday; public function __construct(Carbon $date, Day $day, bool $isPublicHoliday, Closure $paidHours, Closure $vacation) { $this->date = $date; $this->day = $day->day; $this->state = $day->state; $this->targetHours = $day->hours; $this->isPublicHoliday = $isPublicHoliday; $this->paidHours = $paidHours; $this->vacation = $vacation; } public function getDate() { return $this->date; } public function getDateForHumans() { return app(DateFormatter::class) ->formatDateForView($this->date); } public function isWorkingDay() { return $this->state && !$this->isPublicHoliday(); } public function isPublicHoliday() { return $this->isPublicHoliday; } public function isVacationDay() { return $this->getVacation()->isPositive(); } public function getTargetHours() { return $this->targetHours; } public function getPaidHours() { return call_user_func($this->paidHours, $this); } public function getVacation() { if (!$this->state || $this->isPublicHoliday()) { return BigDecimal::zero(); } return call_user_func($this->vacation); } public function toArray() { return [ 'date' => $this->date, 'day' => $this->day, 'state' => $this->state, 'paidHours' => $this->getPaidHours(), 'targetHours' => $this->targetHours, 'vacation' => $this->getVacation(), 'isPublicHoliday' => $this->isPublicHoliday ]; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/AbsenceCalendar/EmployeeAbsenceCalendar.php
app/AbsenceCalendar/EmployeeAbsenceCalendar.php
<?php namespace App\AbsenceCalendar; use Carbon\Carbon; use App\Models\User; use App\Models\Location; use Carbon\CarbonPeriod; use Brick\Math\BigDecimal; use Brick\Math\RoundingMode; class EmployeeAbsenceCalendar implements AbsenceCalendar { protected $employee; protected $location; protected $period; protected $startDay; protected $endDay; public $days; public function __construct(User $employee, Location $location, CarbonPeriod $period) { $this->employee = $employee; $this->location = $location; $this->startDay = $period->getStartDate()->toImmutable(); $this->endDay = $period->getEndDate()->toImmutable(); $this->period = new CarbonPeriod( $period->getStartDate()->startOfDay(), $period->getEndDate()->endOfDay() ); $this->calculateDays(); } protected function calculateDays() { $this->days = collect(); foreach ($this->period as $date) { $this->days->add(new EmployeeAbsenceCalendarDay( $date, $this->employee->targetHourDayForDate($date), $this->location->publicHolidayForDate($date) ? true : false, $this->calculatePaidHours(), $this->calculateVacation($date) )); } $this->period->rewind(); } /** * Filters dates which are a public holidays or not a normal working day * for the employee e.g. weekends. * * @return Collection $days */ public function getWorkingDays() { return $this->days->filter(fn($day) => $day->isWorkingDay()); } public function getVacationDays() { return $this->days->filter(fn($day) => $day->isVacationDay()); } protected function calculateVacation($date) { return function () use ($date) { if ($this->isHalfDayVacation($date)) { return BigDecimal::of('0.5'); } return BigDecimal::one(); }; } protected function calculatePaidHours() { /** * @var Day $absenceDay */ return function ($absenceDay) { //if we end up having start and end date on the the same day if ($this->startAndEndDayAreSame()) { $calcHours = BigDecimal::of($this->startDay->diffInMinutes($this->endDay)) ->dividedBy('60', 2, RoundingMode::HALF_EVEN); return $calcHours->isGreaterThanOrEqualTo($absenceDay->getTargetHours()) ? $absenceDay->getTargetHours() : $calcHours; } //else we need to calculate the paid hours for that day $diffInHours = $this->diffHoursToStartOrEndOfDay($absenceDay->getDate()); return $absenceDay->getTargetHours() ->isGreaterThanOrEqualTo($diffInHours) ? $diffInHours : $absenceDay->getTargetHours(); }; } protected function diffHoursToStartOrEndOfDay(Carbon $date) { $diffInHours = BigDecimal::of('24'); $date = $date->toImmutable(); if ($this->startDay->isSameDay($date)) { //hours from start to end of day $diffInHours = BigDecimal::of($this->startDay->diffInMinutes($date->addDay()->startOfDay())) ->dividedBy('60', 2, RoundingMode::HALF_EVEN); } elseif ($date->isSameDay($this->endDay)) { //hours from start of day to end of end day $diffInHours = BigDecimal::of($date->startOfDay()->diffInMinutes($this->endDay)) ->dividedBy('60', 2, RoundingMode::HALF_EVEN); } return $diffInHours; } protected function startAndEndDayAreSame() { return $this->startDay->isSameDay($this->endDay); } protected function isHalfDayVacation(Carbon $date) { $diffInHours = BigDecimal::zero(); if ($this->startAndEndDayAreSame()) { $diffInHours = BigDecimal::of($this->startDay->diffInMinutes($this->endDay)) ->dividedBy('60', 2, RoundingMode::HALF_EVEN); } else { $diffInHours = $this->diffHoursToStartOrEndOfDay($date); } return $diffInHours->isLessThanOrEqualTo( $this->employee ->targetHoursForDate($date) ->dividedBy('2', 2, RoundingMode::HALF_EVEN) ); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/AbsenceCalendar/AbsenceCalendarDay.php
app/AbsenceCalendar/AbsenceCalendarDay.php
<?php namespace App\AbsenceCalendar; interface AbsenceCalendarDay { public function getDate(); public function isPublicHoliday(); public function isWorkingDay(); public function getPaidHours(); public function isVacationDay(); public function getVacation(); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/StateMachine/WorkingSession/Transitions/PausedToStopped.php
app/StateMachine/WorkingSession/Transitions/PausedToStopped.php
<?php namespace App\StateMachine\WorkingSession\Transitions; use App\Models\WorkingSession; use Spatie\ModelStates\Transition; use App\Facades\WorkingSessionToTimeTracking; use App\StateMachine\WorkingSession\Places\Running; use App\StateMachine\WorkingSession\Places\Stopped; use DB; class PausedToStopped extends Transition { private WorkingSession $workingSession; public function __construct(WorkingSession $workingSession) { $this->workingSession = $workingSession; } public function handle() { $this->workingSession->status = new Stopped($this->workingSession); $now = now(); $this->workingSession->actions()->create([ 'action_type' => 'pause_ends_at', 'action_time' => $now, ]); $this->workingSession->actions()->create([ 'action_type' => 'ends_at', 'action_time' => $now, ]); $converter = WorkingSessionToTimeTracking::fromCollection($this->workingSession->actions); DB::transaction(function () use ($converter) { $trackedTime = $this->workingSession ->user ->timeTrackings() ->create(array_merge([ 'location_id' => $this->workingSession->location->id, 'starts_at' => $this->workingSession->starts_at, 'ends_at' => $this->workingSession->ends_at ], $converter->timeTracking())); $trackedTime->pauseTimes()->createMany($converter->pauseTimes()); $trackedTime->updatePauseTime(); $this->workingSession->actions->each->delete(); $this->workingSession->save(); }); return $this->workingSession->fresh(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/StateMachine/WorkingSession/Transitions/RunningToPaused.php
app/StateMachine/WorkingSession/Transitions/RunningToPaused.php
<?php namespace App\StateMachine\WorkingSession\Transitions; use App\Models\WorkingSession; use Spatie\ModelStates\Transition; use App\StateMachine\WorkingSession\Places\Paused; class RunningToPaused extends Transition { private WorkingSession $workingSession; public function __construct(WorkingSession $workingSession) { $this->workingSession = $workingSession; } public function handle(): WorkingSession { $this->workingSession->status = new Paused($this->workingSession); $this->workingSession->actions()->create([ 'action_type' => 'pause_starts_at', 'action_time' => now(), ]); $this->workingSession->save(); return $this->workingSession->fresh(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/StateMachine/WorkingSession/Transitions/RunningToStopped.php
app/StateMachine/WorkingSession/Transitions/RunningToStopped.php
<?php namespace App\StateMachine\WorkingSession\Transitions; use App\Models\WorkingSession; use App\Actions\AddTimeTracking; use Spatie\ModelStates\Transition; use App\Facades\WorkingSessionToTimeTracking; use App\StateMachine\WorkingSession\Places\Stopped; use DB; class RunningToStopped extends Transition { private WorkingSession $workingSession; public function __construct(WorkingSession $workingSession) { $this->workingSession = $workingSession; } public function handle() : WorkingSession { $this->workingSession->status = new Stopped($this->workingSession); $now = now(); $this->workingSession->actions()->create([ 'action_type' => 'ends_at', 'action_time' => $now, ]); $converter = WorkingSessionToTimeTracking::fromCollection($this->workingSession->actions); DB::transaction(function () use ($converter) { $trackedTime = $this->workingSession ->user ->timeTrackings() ->create(array_merge([ 'location_id' => $this->workingSession->location->id, 'starts_at' => $this->workingSession->starts_at, 'ends_at' => $this->workingSession->ends_at ], $converter->timeTracking())); $trackedTime->pauseTimes()->createMany($converter->pauseTimes()); $trackedTime->updatePauseTime(); $this->workingSession->actions->each->delete(); $this->workingSession->save(); }); return $this->workingSession->fresh(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/StateMachine/WorkingSession/Transitions/PunchIn.php
app/StateMachine/WorkingSession/Transitions/PunchIn.php
<?php namespace App\StateMachine\WorkingSession\Transitions; use App\Models\WorkingSession; use App\StateMachine\WorkingSession\Places\Running; use Spatie\ModelStates\Transition; class PunchIn extends Transition { private WorkingSession $workingSession; public function __construct(WorkingSession $workingSession) { $this->workingSession = $workingSession; } public function handle(): WorkingSession { $this->workingSession->status = new Running($this->workingSession); $this->workingSession->actions()->create([ 'action_type' => 'starts_at', 'action_time' => now(), ]); $this->workingSession->save(); return $this->workingSession->fresh(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/StateMachine/WorkingSession/Transitions/PausedToRunning.php
app/StateMachine/WorkingSession/Transitions/PausedToRunning.php
<?php namespace App\StateMachine\WorkingSession\Transitions; use App\Models\WorkingSession; use Spatie\ModelStates\Transition; use App\StateMachine\WorkingSession\Places\Running; class PausedToRunning extends Transition { private WorkingSession $workingSession; public function __construct(WorkingSession $workingSession) { $this->workingSession = $workingSession; } public function handle(): WorkingSession { $this->workingSession->status = new Running($this->workingSession); $this->workingSession->actions()->create([ 'action_type' => 'pause_ends_at', 'action_time' => now(), ]); $this->workingSession->save(); return $this->workingSession->fresh(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/StateMachine/WorkingSession/Places/Running.php
app/StateMachine/WorkingSession/Places/Running.php
<?php namespace App\StateMachine\WorkingSession\Places; use DateTime; class Running extends WorkingSessionState { public static $name = 'running'; public static function label() : string { return __('Punch in'); } public function since() : ?DateTime { return $this->getModel() ->actions() ->latest() ->firstWhere('action_type', 'starts_at') ->action_time; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/StateMachine/WorkingSession/Places/Stopped.php
app/StateMachine/WorkingSession/Places/Stopped.php
<?php namespace App\StateMachine\WorkingSession\Places; use DateTime; class Stopped extends WorkingSessionState { public static $name = 'stopped'; public static function label() : string { return __('Leave'); } public function since() : ?DateTime { return null; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/StateMachine/WorkingSession/Places/Paused.php
app/StateMachine/WorkingSession/Places/Paused.php
<?php namespace App\StateMachine\WorkingSession\Places; use DateTime; class Paused extends WorkingSessionState { public static $name = 'paused'; public static function label() : string { return __('Pause'); } public function since() : ?DateTime { return $this->getModel() ->actions() ->latest() ->firstWhere('action_type', 'pause_starts_at') ->action_time; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/StateMachine/WorkingSession/Places/WorkingSessionState.php
app/StateMachine/WorkingSession/Places/WorkingSessionState.php
<?php namespace App\StateMachine\WorkingSession\Places; use Spatie\ModelStates\State; use Spatie\ModelStates\StateConfig; use App\StateMachine\WorkingSession\Transitions\PunchIn; use App\StateMachine\WorkingSession\Transitions\PausedToRunning; use App\StateMachine\WorkingSession\Transitions\PausedToStopped; use App\StateMachine\WorkingSession\Transitions\RunningToPaused; use App\StateMachine\WorkingSession\Transitions\RunningToStopped; abstract class WorkingSessionState extends State { public static function config(): StateConfig { return parent::config() ->default(Stopped::class) ->allowTransition(Stopped::class, Running::class, PunchIn::class) ->allowTransition(Running::class, Paused::class, RunningToPaused::class) ->allowTransition(Paused::class, Running::class, PausedToRunning::class) ->allowTransition(Paused::class, Stopped::class, PausedToStopped::class) ->allowTransition(Running::class, Stopped::class, RunningToStopped::class); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/DeleteAccount.php
app/Actions/DeleteAccount.php
<?php namespace App\Actions; use App\Contracts\DeletesAccounts; class DeleteAccount implements DeletesAccounts { /** * Delete the given account. * * @param mixed $account * @return void */ public function delete($account) { $account->purge(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/UpdateAbsenceType.php
app/Actions/UpdateAbsenceType.php
<?php namespace App\Actions; use App\Models\AbsenceType; use App\Contracts\UpdatesAbsenceType; use Illuminate\Support\Facades\Validator; class UpdateAbsenceType implements UpdatesAbsenceType { public function update(AbsenceType $absenceType, array $data, array $assignedUsers = null) { Validator::make($data, [ 'title' => ['required', 'string', 'max:255'], 'affect_vacation_times' => ['required', 'boolean'], 'affect_evaluations' => ['required','boolean'], 'evaluation_calculation_setting' => ['required_if:affect_evaluations,true'], 'regard_holidays' => ['required', 'boolean'], 'assign_new_users' => ['required', 'boolean'], 'remove_working_sessions_on_confirm' => ['required', 'boolean'], ])->validateWithBag('updateAbsenceType'); $absenceType->update($data); $absenceType->users()->sync($assignedUsers); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/AddPublicHoliday.php
app/Actions/AddPublicHoliday.php
<?php namespace App\Actions; use App\Models\Location; use App\Formatter\DateFormatter; use App\Contracts\AddsPublicHoliday; use Illuminate\Support\Facades\Validator; class AddPublicHoliday implements AddsPublicHoliday { public $dateFormatter; public function __construct(DateFormatter $dateFormatter) { $this->dateFormatter = $dateFormatter; } public function add(Location $location, array $data): void { Validator::make($data, [ 'name' => ['required', 'string', 'max:255'], 'date' => ['required', $this->dateFormatter->dateFormatRule()], 'half_day' => ['required', 'boolean'] ])->validateWithBag('addPublicHoliday'); $location->publicHolidays()->create([ 'title' => $data['name'], 'day' => $this->dateFormatter->strToDate($data['date']), 'public_holiday_half_day' => $data['half_day'] ]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/UpdateTimeTracking.php
app/Actions/UpdateTimeTracking.php
<?php namespace App\Actions; use DB; use Carbon\Carbon; use App\Models\User; use App\Models\Location; use Carbon\CarbonPeriod; use Illuminate\Support\Arr; use App\Formatter\DateFormatter; use Laravel\Jetstream\Jetstream; use App\Facades\PeriodCalculator; use Illuminate\Support\Facades\Gate; use App\Contracts\UpdatesTimeTracking; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\ValidationException; class UpdateTimeTracking implements UpdatesTimeTracking { public $dateFormatter; public function __construct(DateFormatter $dateFormatter) { $this->dateFormatter = $dateFormatter; } public function update(User $user, Location $location, int $managingTimeTrackingForId, int $timeTrackingId, array $data, array $pauseTimes) { Gate::forUser($user)->authorize('updateTimeTracking', [ TimeTracking::class, $managingTimeTrackingForId, $location ]); Validator::make(array_merge($data, [ 'time_tracking_id' => $timeTrackingId ]),[ 'starts_at' => ['required', $this->dateFormatter->dateTimeFormatRule() ], 'ends_at' => ['required', $this->dateFormatter->dateTimeFormatRule() , 'after_or_equal:starts_at'], 'description' => ['nullable', 'string'], 'time_tracking_id' => ['required', 'exists:time_trackings,id'], ])->validateWithBag('addTimeTracking'); $startsAt = $this->dateFormatter->timeStrToCarbon($data['starts_at']); $endsAt = $this->dateFormatter->timeStrToCarbon($data['ends_at']); $updatingTimeTrackingFor = Jetstream::findUserByIdOrFail($managingTimeTrackingForId); $this->ensureDateIsNotBeforeEmploymentDate($updatingTimeTrackingFor, $startsAt); $this->ensureDateIsNotTooFarInTheFuture($endsAt); $this->ensureGivenTimeIsNotOverlappingWithExisting($updatingTimeTrackingFor, $startsAt, $endsAt, $timeTrackingId); $this->validatePauseTimes( PeriodCalculator::fromTimesArray($pauseTimes), $startsAt, $endsAt ); $trackedTime = $location->timeTrackings()->whereKey($timeTrackingId)->first(); DB::transaction(function () use ($trackedTime, $startsAt, $endsAt, $data, $pauseTimes, $updatingTimeTrackingFor) { $trackedTime->update(array_merge([ 'user_id' => $updatingTimeTrackingFor->id, 'starts_at' => $startsAt, 'ends_at' => $endsAt, ], Arr::except($data, ['starts_at','ends_at','time_tracking_id']))); $trackedTime->pauseTimes->each->delete(); $trackedTime->pauseTimes()->createMany($pauseTimes); $trackedTime->updatePauseTime(); }); } protected function validatePauseTimes($pauseTimePeriodCalculator, $startsAt, $endsAt) { if (!$pauseTimePeriodCalculator->hasPeriods()) { return; } $pauseTimePeriodCalculator->periods->each(function ($period, $index) use ($pauseTimePeriodCalculator, $startsAt, $endsAt) { $this->ensurePeriodIsNotTooSmall($period); $this->ensurePeriodsAreNotOverlapping($pauseTimePeriodCalculator->periods, $index, $period); $this->ensurePeriodWithinWorkingHours($period, $startsAt, $endsAt); }); } protected function ensureDateIsNotTooFarInTheFuture($endsAt) { if ($endsAt->isAfter(Carbon::now()->endOfDay())) { throw ValidationException::withMessages([ 'date' => [ __('Date should not be in the future.') ], ])->errorBag('addTimeTracking'); } } protected function ensureDateIsNotBeforeEmploymentDate($user, $startsAt) { if ($user->date_of_employment) { if ($startsAt->isBefore($user->date_of_employment)) { throw ValidationException::withMessages([ 'date' => [ __('Date should not before employment date.') ], ])->errorBag('addTimeTracking'); } } } protected function ensureGivenTimeIsNotOverlappingWithExisting($user, $startsAt, $endsAt, $timeTrackingId) { if ($user->timeTrackings()->where(function ($query) use ($startsAt, $endsAt, $timeTrackingId) { $query->whereBetween('starts_at', [$startsAt, $endsAt]) ->orWhereBetween('ends_at', [$startsAt, $endsAt]) ->orWhere(function ($query) use ($startsAt, $endsAt) { return $query->where('ends_at','>',$endsAt) ->where('starts_at','<', $startsAt); }); })->where('id', '!=', [$timeTrackingId])->count() > 0 ) { throw ValidationException::withMessages([ 'date' => [ __('The given time period overlapps with an existing entry.') ], ])->errorBag('addTimeTracking'); } } protected function ensurePeriodIsNotTooSmall($period) { if ($period->count() <= 1) { throw ValidationException::withMessages([ 'pause' => [ __('Given pause time is too small.') ], ])->errorBag('addTimeTracking'); } } protected function ensurePeriodWithinWorkingHours($period, $startsAt, $endsAt) { if (!$period->startsAfterOrAt($startsAt) || !$period->endsBeforeOrAt($endsAt)) { throw ValidationException::withMessages([ 'pause' => [ __('Pause is not between working hours.') ], ])->errorBag('addTimeTracking'); } } protected function ensurePeriodsAreNotOverlapping($periods, $index, $period) { $haystack = Arr::except($periods, [$index]); foreach ($haystack as $needle) { /** * @var CarbonPeriod $period */ if ($period->overlaps($needle)) { throw ValidationException::withMessages([ 'pause' => [ __('Overlapping pause time detected.') ], ])->errorBag('addTimeTracking'); } } } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/FilterEvaluation.php
app/Actions/FilterEvaluation.php
<?php namespace App\Actions; use Carbon\Carbon; use App\Models\User; use App\Report\Report; use App\Models\Location; use Carbon\CarbonPeriod; use App\Formatter\DateFormatter; use App\Contracts\FiltersEvaluation; use App\Report\ReportBuilder; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\ValidationException; class FilterEvaluation implements FiltersEvaluation { protected $dateFormatter; public function __construct(DateFormatter $dateFormatter) { $this->dateFormatter = $dateFormatter; } /** * Approves employee absence * * @param User $employee * @param Location $location * @param int $absenceId * @return void */ public function filter(User $employee, Location $location, array $filter) { Validator::make([ 'fromDate' => $filter['fromDate'], 'toDate' => $filter['toDate'] ],[ 'fromDate' => ['required', $this->dateFormatter->dateFormatRule()], 'toDate' => ['required', $this->dateFormatter->dateFormatRule()] ])->validateWithBag('filterEmployeeReport'); if ($this->dateFormatter->strToDate($filter['fromDate'])->diffInDays( $this->dateFormatter->strToDate($filter['toDate']) ) > 50) { throw ValidationException::withMessages([ 'fromDate' => [ __('Chosen date interval is too big.') ], ])->errorBag('filterEmployeeReport'); } if ($employee->date_of_employment) { if ($this->dateFormatter->strToDate($filter['fromDate'])->lt($employee->date_of_employment)) { throw ValidationException::withMessages([ 'fromDate' => [__('The start date should not be set before the employment date.')], ])->errorBag('filterEmployeeReport'); } } return (new ReportBuilder( $employee, $location, $this->dateFormatter->strToDate($filter['fromDate']), $this->dateFormatter->strToDate($filter['toDate']) ))->build(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/UpdateEmployeeProfile.php
app/Actions/UpdateEmployeeProfile.php
<?php namespace App\Actions; use App\Formatter\DateFormatter; use App\Contracts\UpdatesEmployeeProfile; use Illuminate\Support\Facades\Validator; class UpdateEmployeeProfile implements UpdatesEmployeeProfile { private $dateFormatter; public function __construct(DateFormatter $dateFormatter) { $this->dateFormatter = $dateFormatter; } /** * Update employee profile * * @param mixed $user * @param array $data * @return void */ public function update($user, $data) { Validator::make($data, [ 'name' => ['required','string','max:255'], 'date_of_employment' => ['nullable', $this->dateFormatter->dateFormatRule()], 'opening_overtime_balance' => ['nullable','numeric'], 'is_account_admin' => ['required','boolean'], ])->validateWithBag('saveEmployee'); $user->forceFill([ 'name' => $data['name'], 'date_of_employment' => $this->dateFormatter->strToDate($data['date_of_employment']), 'opening_overtime_balance' => $data['opening_overtime_balance'], 'is_account_admin' => $data['is_account_admin'], ])->save(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/RemoveLocationMember.php
app/Actions/RemoveLocationMember.php
<?php namespace App\Actions; use Illuminate\Support\Facades\Gate; use App\Contracts\RemovesLocationMembers; use Illuminate\Validation\ValidationException; use Illuminate\Auth\Access\AuthorizationException; class RemoveLocationMember implements RemovesLocationMembers { /** * Remove the team member from the given team. * * @param mixed $user * @param mixed $location * @param mixed $locationMember * @return void */ public function remove($user, $location, $locationMember) { $this->authorize($user, $location, $locationMember); $this->ensureUserDoesNotOwnLocation($locationMember, $location); $location->removeUser($locationMember); } /** * Authorize that the user can remove the team member. * * @param mixed $user * @param mixed $location * @param mixed $locationMember * @return void */ protected function authorize($user, $location, $locationMember) { if (! Gate::forUser($user)->check('removeLocationMember', $location) && $user->id !== $locationMember->id ) { throw new AuthorizationException; } } /** * Ensure that the currently authenticated user does not own the team. * * @param mixed $locationMember * @param mixed $location * @return void */ protected function ensureUserDoesNotOwnLocation($locationMember, $location) { if ($locationMember->id === $location->owner->id) { throw ValidationException::withMessages([ 'location' => [__('You may not leave a location that you created.')], ])->errorBag('removeLocationMember'); } } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/RemoveDefaultRestingTime.php
app/Actions/RemoveDefaultRestingTime.php
<?php namespace App\Actions; use App\Models\Location; use App\Contracts\RemovesDefaultRestingTime; class RemoveDefaultRestingTime implements RemovesDefaultRestingTime { /** * Remove default resting time from a location * * @param mixed $location * @param mixed $defaultRestingTimeIdBeingRemoved * @return void */ public function remove(Location $location, $defaultRestingTimeIdBeingRemoved) { $location->defaultRestingTimes()->whereKey($defaultRestingTimeIdBeingRemoved)->delete(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/DeleteLocation.php
app/Actions/DeleteLocation.php
<?php namespace App\Actions; use App\Contracts\DeletesLocations; class DeleteLocation implements DeletesLocations { /** * Delete the given location. * * @param mixed $location * @return void */ public function delete($location) { $location->purge(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/RemoveTargetHour.php
app/Actions/RemoveTargetHour.php
<?php namespace App\Actions; use App\Models\User; use App\Contracts\RemovesTargetHour; class RemoveTargetHour implements RemovesTargetHour { /** * Remove target hours from employee * * @param mixed $employee * @param mixed $targetHourIdBeingRemoved * @return void */ public function remove(User $employee, $targetHourIdBeingRemoved) { $employee->targetHours()->whereKey($targetHourIdBeingRemoved)->delete(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/RemoveLocation.php
app/Actions/RemoveLocation.php
<?php namespace App\Actions; use App\Models\User; use App\Models\Location; use App\Contracts\RemovesLocation; use App\Contracts\DeletesLocations; class RemoveLocation implements RemovesLocation { public $deleter; public function __construct(DeletesLocations $deleter) { $this->deleter = $deleter; } public function remove(User $employee, $removeLocationId) { $this->deleter->delete( Location::findOrFail($removeLocationId) ); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/InviteLocationMember.php
app/Actions/InviteLocationMember.php
<?php namespace App\Actions; use App\Mail\LocationInvitation; use Laravel\Jetstream\Jetstream; use Laravel\Jetstream\Rules\Role; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Mail; use App\Contracts\InvitesLocationMembers; use Illuminate\Support\Facades\Validator; class InviteLocationMember implements InvitesLocationMembers { public function invite($user, $location, string $email, string $role = null) { Gate::forUser($user)->authorize('addLocationMember', $location); $this->validate($location, $email, $role); $invitation = $location->locationInvitations()->create([ 'email' => $email, 'role' => $role, ]); Mail::to($email)->send(new LocationInvitation($invitation)); } /** * Validate the invite member operation. * * @param mixed $location * @param string $email * @param string|null $role * @return void */ protected function validate($location, string $email, ?string $role) { Validator::make([ 'email' => $email, 'role' => $role, ], $this->rules(), [ 'email.unique' => __('This user has already been invited.'), ])->after( $this->ensureUserIsNotAlreadyOnLocation($location, $email) )->validateWithBag('addLocationMember'); } /** * Get the validation rules for inviting a location member. * * @return array */ protected function rules() { return array_filter([ 'email' => ['required', 'email', 'unique:location_invitations'], 'role' => Jetstream::hasRoles() ? ['required', 'string', new Role] : null, ]); } /** * Ensure that the user is not already on the location. * * @param mixed $location * @param string $email * @return \Closure */ protected function ensureUserIsNotAlreadyOnLocation($location, string $email) { return function ($validator) use ($location, $email) { $validator->errors()->addIf( $location->hasUserWithEmail($email), 'email', __('This user already belongs to the location.') ); }; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/AddLocationMember.php
app/Actions/AddLocationMember.php
<?php namespace App\Actions; use Laravel\Jetstream\Jetstream; use Laravel\Jetstream\Rules\Role; use App\Contracts\DeletesAccounts; use Illuminate\Support\Facades\DB; use App\Contracts\DeletesLocations; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Gate; use App\Contracts\AddsLocationMembers; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\ValidationException; class AddLocationMember implements AddsLocationMembers { public $deletesAccounts; public $deletesLocations; public function __construct(DeletesAccounts $deletesAccounts, DeletesLocations $deletesLocations) { $this->deletesAccounts = $deletesAccounts; $this->deletesLocations = $deletesLocations; } /** * Add a new team member to the given team. * * @param mixed $user * @param mixed $location * @param string $email * @param string|null $role * @return void */ public function add($user, $location, string $email, string $role = null) { Gate::forUser($user)->authorize('addLocationMember', $location); $this->validate($location, $email, $role); $this->ensureAuthenticatedUserHasBeenInvited($email); $newLocationMember = Jetstream::findUserByEmailOrFail($email); DB::transaction(function () use ($newLocationMember, $location, $role) { // we need to purge the users account / locations once he enters an invitation $this->deletesAccounts->delete($newLocationMember->ownedAccount); $newLocationMember->ownedLocations->each(function ($location) { $this->deletesLocations->delete($location); }); // assign location and role to user $location->users()->attach( $newLocationMember, ['role' => $role] ); // update current location for new member $newLocationMember->switchLocation($location); // update current account for new member $newLocationMember->switchAccount($location->account); // assign existing absence types to user $newLocationMember->absenceTypes()->sync( $location->absentTypesToBeAssignedToNewUsers ); }); } protected function ensureAuthenticatedUserHasBeenInvited(string $email) { if (!Auth::user()->hasEmail($email)) { throw ValidationException::withMessages([ 'email' => [__('Sorry, you were not invited.')], ])->errorBag('addLocationMember'); } } /** * Validate the add member operation. * * @param mixed $team * @param string $email * @param string|null $role * @return void */ protected function validate($location, string $email, ?string $role) { Validator::make([ 'email' => $email, 'role' => $role, ], $this->rules(), [ 'email.exists' => __('We were unable to find a registered user with this email address.'), ])->after( $this->ensureUserIsNotAlreadyInLocation($location, $email) )->validateWithBag('addLocationMember'); } /** * Get the validation rules for adding a team member. * * @return array */ protected function rules() { return [ 'email' => ['required', 'email', 'exists:users'], 'role' => Jetstream::hasRoles() ? ['required', 'string', new Role] : null, ]; } /** * Ensure that the user is not already on the location. * * @param mixed $location * @param string $email * @return \Closure */ protected function ensureUserIsNotAlreadyInLocation($location, string $email) { return function ($validator) use ($location, $email) { $validator->errors()->addIf( $location->hasUserWithEmail($email), 'email', __('This user already belongs to the location.') ); }; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/AddTimeTracking.php
app/Actions/AddTimeTracking.php
<?php namespace App\Actions; use DB; use Carbon\Carbon; use App\Models\User; use App\Models\Location; use Carbon\CarbonPeriod; use Illuminate\Support\Arr; use App\Models\TimeTracking; use App\Formatter\DateFormatter; use Laravel\Jetstream\Jetstream; use App\Facades\PeriodCalculator; use App\Contracts\AddsTimeTrackings; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\ValidationException; class AddTimeTracking implements AddsTimeTrackings { public $dateFormatter; public function __construct(DateFormatter $dateFormatter) { $this->dateFormatter = $dateFormatter; } public function add(User $user, Location $location, int $managingTimeTrackingForId, array $data, array $pauseTimes) { Gate::forUser($user)->authorize('addTimeTracking', [ TimeTracking::class, $managingTimeTrackingForId, $location ]); Validator::make($data,[ 'starts_at' => ['required', $this->dateFormatter->dateTimeFormatRule() ], 'ends_at' => ['required', $this->dateFormatter->dateTimeFormatRule() , 'after_or_equal:starts_at'], 'description' => ['nullable', 'string'] ])->validateWithBag('addTimeTracking'); $startsAt = $this->dateFormatter->timeStrToCarbon($data['starts_at']); $endsAt = $this->dateFormatter->timeStrToCarbon($data['ends_at']); $addingTimeTrackingFor = Jetstream::findUserByIdOrFail($managingTimeTrackingForId); $this->ensureDateIsNotBeforeEmploymentDate($addingTimeTrackingFor, $startsAt); $this->ensureDateIsNotTooFarInTheFuture($endsAt); $this->ensureGivenTimeIsNotOverlappingWithExisting($addingTimeTrackingFor, $startsAt, $endsAt); $this->validatePauseTimes( PeriodCalculator::fromTimesArray($pauseTimes), $startsAt, $endsAt ); DB::transaction(function () use ($addingTimeTrackingFor, $startsAt, $endsAt, $data, $pauseTimes, $location) { $trackedTime = $addingTimeTrackingFor->timeTrackings()->create(array_merge([ 'location_id' => $location->id, 'starts_at' => $startsAt, 'ends_at' => $endsAt, ], Arr::except($data, ['starts_at','ends_at']))); $trackedTime->pauseTimes()->createMany($pauseTimes); $trackedTime->updatePauseTime(); }); } protected function validatePauseTimes($pauseTimePeriodCalculator, $startsAt, $endsAt) { if (!$pauseTimePeriodCalculator->hasPeriods()) { return; } $pauseTimePeriodCalculator->periods->each(function ($period, $index) use ($pauseTimePeriodCalculator, $startsAt, $endsAt) { $this->ensurePeriodIsNotTooSmall($period); $this->ensurePeriodsAreNotOverlapping($pauseTimePeriodCalculator->periods, $index, $period); $this->ensurePeriodWithinWorkingHours($period, $startsAt, $endsAt); }); } protected function ensureDateIsNotTooFarInTheFuture($endsAt) { if ($endsAt->isAfter(Carbon::now()->endOfDay())) { throw ValidationException::withMessages([ 'date' => [ __('Date should not be in the future.') ], ])->errorBag('addTimeTracking'); } } protected function ensureDateIsNotBeforeEmploymentDate($employee, $startsAt) { if ($employee->date_of_employment) { if ($startsAt->isBefore($employee->date_of_employment)) { throw ValidationException::withMessages([ 'date' => [ __('Date should not before employment date.') ], ])->errorBag('addTimeTracking'); } } } protected function ensureGivenTimeIsNotOverlappingWithExisting($employee, $startsAt, $endsAt) { if ($employee->timeTrackings()->where(function ($query) use ($startsAt, $endsAt) { $query->whereBetween('starts_at', [$startsAt, $endsAt]) ->orWhereBetween('ends_at', [$startsAt, $endsAt]) ->orWhere(function ($query) use ($startsAt, $endsAt) { return $query->where('ends_at','>',$endsAt) ->where('starts_at','<', $startsAt); }); })->count() > 0 ) { throw ValidationException::withMessages([ 'date' => [ __('The given time period overlapps with an existing entry.') ], ])->errorBag('addTimeTracking'); } } protected function ensurePeriodIsNotTooSmall($period) { if ($period->count() <= 1) { throw ValidationException::withMessages([ 'pause' => [ __('Given pause time is too small.') ], ])->errorBag('addTimeTracking'); } } protected function ensurePeriodWithinWorkingHours($period, $startsAt, $endsAt) { if (!$period->startsAfterOrAt($startsAt) || !$period->endsBeforeOrAt($endsAt)) { throw ValidationException::withMessages([ 'pause' => [ __('Pause is not between working hours.') ], ])->errorBag('addTimeTracking'); } } protected function ensurePeriodsAreNotOverlapping($periods, $index, $period) { $haystack = Arr::except($periods->toArray(), [$index]); foreach ($haystack as $needle) { /** * @var CarbonPeriod $period */ if ($period->overlaps($needle)) { throw ValidationException::withMessages([ 'pause' => [ __('Overlapping pause time detected.') ], ])->errorBag('addTimeTracking'); } } } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/RemoveAbsence.php
app/Actions/RemoveAbsence.php
<?php namespace App\Actions; use DB; use App\Models\User; use App\Models\Location; use App\Mail\AbsenceRemoved; use App\Contracts\RemovesAbsence; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Mail; class RemoveAbsence implements RemovesAbsence { public function remove(User $user, Location $location, $removesAbsenceId) { tap($location->absences()->whereKey($removesAbsenceId)->first(), function ($absence) use ($user, $location) { Gate::forUser($user)->authorize('removeAbsence', [ Absence::class, $absence, $location ]); $absence->delete(); Mail::to($absence->employee)->send(new AbsenceRemoved()); }); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/RemovePublicHoliday.php
app/Actions/RemovePublicHoliday.php
<?php namespace App\Actions; use App\Models\Location; use App\Contracts\RemovesPublicHoliday; class RemovePublicHoliday implements RemovesPublicHoliday { /** * Remove public holiday from a location * * @param mixed $location * @param mixed $locationMember * @return void */ public function remove(Location $location, $publicHolidayIdBeingRemoved) { $location->publicHolidays()->whereKey($publicHolidayIdBeingRemoved)->delete(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/RemoveTimeTracking.php
app/Actions/RemoveTimeTracking.php
<?php namespace App\Actions; use App\Models\User; use App\Models\Location; use Illuminate\Support\Facades\Gate; use App\Contracts\RemovesTimeTracking; class RemoveTimeTracking implements RemovesTimeTracking { public function remove(User $user, Location $location, int $removeTimeTrackingForId, $timeTrackingId) { tap($location->timeTrackings()->whereKey($timeTrackingId)->first(), function ($timeTracking) use ($user, $location) { Gate::forUser($user)->authorize('removeTimeTracking', [ TimeTracking::class, $timeTracking, $location ]); $timeTracking->delete(); }); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/ApproveAbscence.php
app/Actions/ApproveAbscence.php
<?php namespace App\Actions; use DB; use App\Daybreak; use App\Models\User; use App\Models\Absence; use App\Models\Location; use Carbon\CarbonPeriod; use App\Jobs\SendAbsenceApproved; use App\Contracts\ApprovesAbsence; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Validator; use App\AbsenceCalendar\AbsenceCalculator; use Daybreak\Caldav\Jobs\CreateCaldavEvent; use Illuminate\Validation\ValidationException; use App\AbsenceCalendar\EmployeeAbsenceCalendar; use App\AbsenceCalendar\EmployeeAbsenceCalendarDay; class ApproveAbscence implements ApprovesAbsence { /** * Approves employee absence * * @param User $user * @param Location $location * @param int $absenceId * @return void */ public function approve(User $user, Location $location, $absenceId) { Gate::check('approveAbsence', [App\Model\Absence::class, $location]); Validator::make([ 'absence_id' => $absenceId ], [ 'absence_id' => ['required', 'exists:absences,id'] ])->validateWithBag('approvesAbsence'); $absence = Absence::findOrFail($absenceId); DB::transaction(function () use ($absence, $user) { $this->bookVacationDays($absence); $this->createAbsenceIndex($absence, $user->currentLocation); $absence->markAsConfirmed(); if (Daybreak::hasCaldavFeature()) { CreateCaldavEvent::dispatch($absence) ->afterCommit(); } SendAbsenceApproved::dispatch($absence)->afterCommit(); }); } public function bookVacationDays($absence) { if (!$absence->absenceType->affectsVacation()) { return; } //TODO: distribute absence days between available vacation entitlements $currentVacationEntitlement = $absence->employee->currentVacationEntitlement(); if (!isset($currentVacationEntitlement) || !$currentVacationEntitlement->hasEnoughUnusedVacationDays($absence->vacation_days)) { throw ValidationException::withMessages([ 'error' => [__('Sorry, there is no fitting vacation entitlement for this absence.')], ])->errorBag('approvesAbsence'); } $currentVacationEntitlement->useVacationDays($absence); } public function createAbsenceIndex($absence, $location) { if (!$absence->absenceType->affectsEvaluation()) { return; } $calendar = (new EmployeeAbsenceCalendar( $absence->employee, $location, new CarbonPeriod( $absence->starts_at, $absence->ends_at ) )); $absenceCalculator = new AbsenceCalculator($calendar, $absence->absenceType); if ($absenceCalculator->sumPaidHours() != $absence->paid_hours) { throw ValidationException::withMessages([ 'error' => [__("Paid hours changed from {$absence->paid_hours} to {$absenceCalculator->sumPaidHours()}")], ])->errorBag('approvesAbsence'); } if ($absenceCalculator->sumVacationDays()->compareTo($absence->vacation_days) != 0) { throw ValidationException::withMessages([ 'error' => [__("Vacation days changed from {$absence->vacation_days} to {$absenceCalculator->sumVacationDays()}")], ])->errorBag('approvesAbsence'); } foreach ($absenceCalculator->getDays() as $day) { /** * @var EmployeeAbsenceCalendarDay $day */ $absence->index()->create([ 'date' => $day->getDate(), 'hours' => $day->getPaidHours(), 'absence_type_id' => $absence->absence_type_id, 'user_id' => $absence->employee->id, 'location_id' => $location->id ]); } } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/AddTargetHour.php
app/Actions/AddTargetHour.php
<?php namespace App\Actions; use App\Models\User; use App\Formatter\DateFormatter; use App\Contracts\AddsTargetHours; use App\Rules\NumberHasCorrectScale; use Illuminate\Support\Facades\Validator; class AddTargetHour implements AddsTargetHours { protected $dateFormatter; public function __construct(DateFormatter $dateFormatter) { $this->dateFormatter = $dateFormatter; } /** * Add target hour profile for user * * @param User $user * @param array $targetHour * @return void */ public function add($user, $targetHour, $availbleDays) { Validator::make(array_merge($targetHour, [ 'days' => $availbleDays->count() ]),[ 'start_date' => ['required', $this->dateFormatter->dateFormatRule()], 'days' => ['required', 'gte:1'], 'target_hours' => ['required', 'numeric', new NumberHasCorrectScale($availbleDays->count(), 2)], 'hours_per' => ['required'], ])->validateWithBag('addTargetHour'); $targetHour['start_date'] = app(DateFormatter::class) ->strToDate($targetHour['start_date']); $user->targetHours()->create($targetHour); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/AddDefaultRestingTime.php
app/Actions/AddDefaultRestingTime.php
<?php namespace App\Actions; use App\Contracts\AddsDefaultRestingTime; use Illuminate\Support\Facades\Validator; use DB; class AddDefaultRestingTime implements AddsDefaultRestingTime { public function add($location, array $data) { Validator::make($data, [ 'min_hours' => ['required'], 'duration' => ['required'], ])->validate(); DB::transaction(function () use ($location, $data) { $defaultRestingTime = $location->defaultRestingTimes()->create($data); $location->allUsers()->each(function ($user) use ($defaultRestingTime) { $user->defaultRestingTimes()->attach($defaultRestingTime); }); }); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/UpdateLocationMemberRole.php
app/Actions/UpdateLocationMemberRole.php
<?php namespace App\Actions; use Laravel\Jetstream\Rules\Role; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Validator; use App\Contracts\UpdatesLocationMembersRole; class UpdateLocationMemberRole implements UpdatesLocationMembersRole { /** * Update the role for the given location member. * * @param mixed $user * @param mixed $location * @param string $locationMemberId * @param string $role * @return void */ public function update($user, $location, $locationMemberId, string $role) { Gate::forUser($user)->authorize('updateLocationMember', $location); Validator::make([ 'role' => $role, ], [ 'role' => ['required', 'string', new Role], ])->validate(); $location->users()->updateExistingPivot($locationMemberId, [ 'role' => $role, ]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/TransferVacationEntitlement.php
app/Actions/TransferVacationEntitlement.php
<?php namespace App\Actions; use App\Models\User; use App\Models\VacationEntitlement; use App\Contracts\TransfersVacationEntitlements; use App\Formatter\DateFormatter; class TransferVacationEntitlement implements TransfersVacationEntitlements { protected $dateFormatter; public function __construct(DateFormatter $dateFormatter) { $this->dateFormatter = $dateFormatter; } public function transfer(User $employee, $vacationEntitlementId) { $vacationEntitlementToBeTransferred = VacationEntitlement::findOrFail($vacationEntitlementId); //fetch a possible vacation entitlement candiate $useExistingVacationEntitlement = $employee->vacationEntitlements()->where('ends_at', $vacationEntitlementToBeTransferred->end_of_transfer_period)->first(); if (!empty($useExistingVacationEntitlement)) { $vacationEntitlementToBeTransferred->transferVacationDays($useExistingVacationEntitlement, [ 'days' => $useExistingVacationEntitlement->days->plus($vacationEntitlementToBeTransferred->daysTransferrable()) ]); } else { $newEntitlement = $employee->vacationEntitlements()->create([ 'name' => __('Transferred: :name', ['name' => $vacationEntitlementToBeTransferred->name]), 'expires' => true, 'transfer_remaining' => false, 'starts_at' => $vacationEntitlementToBeTransferred->ends_at, 'ends_at' => $vacationEntitlementToBeTransferred->end_of_transfer_period, 'status' => $vacationEntitlementToBeTransferred->end_of_transfer_period->isPast() ? 'expired' : 'expires' ]); $vacationEntitlementToBeTransferred->transferVacationDays()->attach($newEntitlement, [ 'days' => $vacationEntitlementToBeTransferred->daysTransferrable() ]); } } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/RemoveVacationEntitlement.php
app/Actions/RemoveVacationEntitlement.php
<?php namespace App\Actions; use App\Models\User; use App\Contracts\RemovesVacationEntitlements; class RemoveVacationEntitlement implements RemovesVacationEntitlements { /** * Remove target hours from employee * * @param mixed $employee * @param mixed $vacationEntitlementId * @return void */ public function remove(User $employee, $vacationEntitlementId) { $employee->vacationEntitlements->each(function ($vacationEntitlement) { $vacationEntitlement->usedVacationDays()->each(function ($absence) { tap($absence)->markAsPending()->index()->delete(); }); $vacationEntitlement->usedVacationDays()->detach(); }); $employee->vacationEntitlements()->whereKey($vacationEntitlementId)->delete(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/AddVacationEntitlement.php
app/Actions/AddVacationEntitlement.php
<?php namespace App\Actions; use App\Models\User; use App\Models\Location; use App\Formatter\DateFormatter; use Illuminate\Support\Facades\Validator; use App\Contracts\AddsVacationEntitlements; class AddVacationEntitlement implements AddsVacationEntitlements { protected $dateFormatter; public function __construct(DateFormatter $dateFormatter) { $this->dateFormatter = $dateFormatter; } public function add(User $employee, array $data) { Validator::make($data,[ 'name' => ['required', 'string', 'max:255'], 'starts_at' => ['required', $this->dateFormatter->dateFormatRule()], 'ends_at' => ['required', $this->dateFormatter->dateFormatRule(), 'after_or_equal:starts_at'], 'days' => ['required','numeric','gte:0'], 'expires' => ['required','boolean'], 'transfer_remaining' => ['required', 'boolean'], 'end_of_transfer_period' => ['required_if:transfer_remaining,1','nullable', $this->dateFormatter->dateFormatRule(), 'after_or_equal:ends_at'] ])->validateWithBag('vacationEntitlement'); return $employee->vacationEntitlements()->create( array_merge($data, [ 'status' => $this->resolveStatus($data) ]) ); } public function resolveStatus(array $data) { if (!$data['expires']) { return 'does_not_expire'; } if ($this->dateFormatter->strToDate($data['ends_at'])->isPast()) { return 'expired'; } return 'expires'; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/AddAbsence.php
app/Actions/AddAbsence.php
<?php namespace App\Actions; use App\Models\User; use App\Models\Absence; use App\Models\Location; use Carbon\CarbonPeriod; use App\Models\AbsenceType; use App\Contracts\AddsAbsences; use App\Formatter\DateFormatter; use Laravel\Jetstream\Jetstream; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Validator; use App\AbsenceCalendar\AbsenceCalculator; use App\Mail\NewAbsenceWaitingForApproval; use App\AbsenceCalendar\EmployeeAbsenceCalendar; class AddAbsence implements AddsAbsences { /** * @var DateFormatter */ public $dateFormatter; public function __construct() { $this->dateFormatter = app(DateFormatter::class); } public function add(User $user, Location $location, int $managingAbsenceForId, array $data) { Gate::forUser($user)->authorize('addAbsence', [ Absence::class, $managingAbsenceForId, $location ]); Validator::make($data, [ 'absence_type_id' => 'required', 'starts_at' => [ 'required', $this->dateFormatter->dateTimeFormatRule() ], 'ends_at' => [ 'required', $this->dateFormatter->dateTimeFormatRule(), 'after_or_equal:starts_at' ], 'full_day' => ['required', 'boolean'] ])->validateWithBag('addAbsence'); $startsAt = $this->dateFormatter->timeStrToCarbon($data['starts_at']); $endsAt = $this->dateFormatter->timeStrToCarbon($data['ends_at']); //ignore given time if calculation is based on full day if (isset($data['full_day']) && $data['full_day']) { $startsAt = $startsAt->copy()->startOfDay(); $endsAt = $endsAt->copy()->endOfDay(); } $addingAbsenceFor = Jetstream::findUserByIdOrFail($managingAbsenceForId); $calculator = new AbsenceCalculator( new EmployeeAbsenceCalendar( $addingAbsenceFor, $location, new CarbonPeriod($startsAt, $endsAt) ), AbsenceType::findOrFail($data['absence_type_id']) ); $absence = $addingAbsenceFor->absences()->create( [ 'location_id' => $location->id, 'vacation_days' => $calculator->sumVacationDays(), 'paid_hours' => $calculator->sumPaidHours(), 'starts_at' => $startsAt, 'ends_at' => $endsAt, ] + $data ); Mail::to( $location->allUsers()->filter->hasLocationRole($location, 'admin') )->send(new NewAbsenceWaitingForApproval($absence, $addingAbsenceFor)); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/AddLocation.php
app/Actions/AddLocation.php
<?php namespace App\Actions; use App\Models\User; use App\Models\Account; use App\Contracts\AddsLocation; use Illuminate\Support\Facades\Validator; class AddLocation implements AddsLocation { public function add(Account $account, User $employee, array $data) { Validator::make($data, [ 'owned_by' => ['required', 'exists:users,id'], 'name' => ['required', 'string', 'max:255'], ])->validateWithBag('createLocation'); $account->locations()->create($data); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/ImportPublicHolidays.php
app/Actions/ImportPublicHolidays.php
<?php namespace App\Actions; use App\Holiday\Client; use App\Models\Location; use App\Models\PublicHoliday; use App\Contracts\ImportsPublicHolidays; use Illuminate\Support\Facades\Validator; class ImportPublicHolidays implements ImportsPublicHolidays { public function import(Location $location, $year, $countryCode) { Validator::make([ 'import_country' => $countryCode, 'import_year' => $year ], [ 'import_country' => [ 'required', 'string', 'in:'.collect(config('public_holidays.countries'))->implode('code',','), ], 'import_year' => [ 'required', 'numeric', 'digits:4', 'min:'.date('Y',strtotime('-2 year')), 'max:'.date('Y',strtotime('+1 year')) ] ])->validateWithBag('importPublicHolidays'); $holidays = (new Client(config('public_holidays'))) ->request($countryCode, $year); PublicHoliday::upsert( $this->addLocationIdToArray( $holidays->toCollection()->toArray(), $location ), ['location_id', 'title','day'] ); } protected function addLocationIdToArray(array $array, $location) { $merged = []; foreach ($array as &$row) { $merged[] = array_merge($row, [ 'location_id' => $location->id ]); } return $merged; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/AddAbsenceType.php
app/Actions/AddAbsenceType.php
<?php namespace App\Actions; use App\Models\Location; use App\Contracts\AddsAbsenceType; use Illuminate\Support\Facades\Validator; class AddAbsenceType implements AddsAbsenceType { public function add(Location $location, array $data, array $assignedUsers = null) { Validator::make($data, [ 'title' => ['required', 'string', 'max:255'], 'affect_vacation_times' => ['required', 'boolean'], 'affect_evaluations' => ['required','boolean'], 'evaluation_calculation_setting' => ['required_if:affect_evaluations,true'], 'regard_holidays' => ['required', 'boolean'], 'assign_new_users' => ['required', 'boolean'], 'remove_working_sessions_on_confirm' => ['required', 'boolean'], ])->validateWithBag('createAbsenceType'); $absentType = $location->absentTypes()->create($data); $absentType->users()->sync($assignedUsers); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/UpdateLocationName.php
app/Actions/UpdateLocationName.php
<?php namespace App\Actions; use Illuminate\Support\Facades\Gate; use App\Contracts\UpdatesLocationNames; use Illuminate\Support\Facades\Validator; class UpdateLocationName implements UpdatesLocationNames { /** * Validate and update the given team's name. * * @param mixed $user * @param mixed $location * @param array $input * @return void */ public function update($user, $location, array $input) { Gate::forUser($user)->authorize('update', $location); Validator::make($input, [ 'name' => ['required', 'string', 'max:255'], ])->validateWithBag('updateLocationName'); $location->forceFill([ 'name' => $input['name'], ])->save(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/RemoveAbsenceType.php
app/Actions/RemoveAbsenceType.php
<?php namespace App\Actions; use App\Models\Location; use App\Contracts\RemovesAbsenceType; class RemoveAbsenceType implements RemovesAbsenceType { public function remove(Location $location, $absenceTypeId) { $location->absentTypes()->whereKey($absenceTypeId)->delete(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/Fortify/UpdateUserProfileInformation.php
app/Actions/Fortify/UpdateUserProfileInformation.php
<?php namespace App\Actions\Fortify; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rule; use Laravel\Fortify\Contracts\UpdatesUserProfileInformation; class UpdateUserProfileInformation implements UpdatesUserProfileInformation { /** * Validate and update the given user's profile information. * * @param mixed $user * @param array $input * @return void */ public function update($user, array $input) { Validator::make($input, [ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)], 'photo' => ['nullable', 'image', 'max:1024'], ])->validateWithBag('updateProfileInformation'); if (isset($input['photo'])) { $user->updateProfilePhoto($input['photo']); } if ($input['email'] !== $user->email && $user instanceof MustVerifyEmail) { $this->updateVerifiedUser($user, $input); } else { $user->forceFill([ 'name' => $input['name'], 'email' => $input['email'], ])->save(); } } /** * Update the given verified user's profile information. * * @param mixed $user * @param array $input * @return void */ protected function updateVerifiedUser($user, array $input) { $user->forceFill([ 'name' => $input['name'], 'email' => $input['email'], 'email_verified_at' => null, ])->save(); $user->sendEmailVerificationNotification(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/Fortify/UpdateUserPassword.php
app/Actions/Fortify/UpdateUserPassword.php
<?php namespace App\Actions\Fortify; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Laravel\Fortify\Contracts\UpdatesUserPasswords; class UpdateUserPassword implements UpdatesUserPasswords { use PasswordValidationRules; /** * Validate and update the user's password. * * @param mixed $user * @param array $input * @return void */ public function update($user, array $input) { Validator::make($input, [ 'current_password' => ['required', 'string'], 'password' => $this->passwordRules(), ])->after(function ($validator) use ($user, $input) { if (! Hash::check($input['current_password'], $user->password)) { $validator->errors()->add('current_password', __('The provided password does not match your current password.')); } })->validateWithBag('updatePassword'); $user->forceFill([ 'password' => Hash::make($input['password']), ])->save(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/Fortify/CreateNewUser.php
app/Actions/Fortify/CreateNewUser.php
<?php namespace App\Actions\Fortify; use Carbon\Carbon; use App\Models\User; use App\Models\Account; use App\Models\Duration; use App\Models\Location; use Laravel\Jetstream\Jetstream; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Laravel\Fortify\Contracts\CreatesNewUsers; class CreateNewUser implements CreatesNewUsers { use PasswordValidationRules; /** * Create a newly registered user. * * @param array $input * @return \App\Models\User */ public function create(array $input) { Validator::make($input, [ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'password' => $this->passwordRules(), 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['required', 'accepted'] : '', ])->validate(); return DB::transaction(function () use ($input) { return tap(User::create([ 'name' => $input['name'], 'email' => $input['email'], 'password' => Hash::make($input['password']), 'date_of_employment' => Carbon::today() ]), function (User $user) { /* |-------------------------------------------------------------------------- | Set up a new user environment. |-------------------------------------------------------------------------- */ //create new account for user $this->createAccount($user); //create default target hours for user $this->createDefaultTargetHours($user); //create new location for user $location = $this->createLocation($user); //create and assign default absent types $this->createDefaultAbsentTypes($user, $location); //create default resting times for user $this->createDefaultRestingTime($user, $location); }); }); } public function createDefaultRestingTime($user, $location) { $defaultRestingTimes = $location->defaultRestingTimes()->createMany([ [ 'min_hours' => new Duration(21600), //6*60*60 'duration' => new Duration(1800) //30*60 ], [ 'min_hours' => new Duration(39600), //11*60*60 'duration' => new Duration(2700) //45*60 ] ]); $user->defaultRestingTimes()->sync($defaultRestingTimes); } /** * Create the default Location. * * @param \App\Models\User $user * @return void */ public function createAccount(User $user) { $account = Account::forceCreate([ 'owned_by' => $user->id, 'name' => explode(' ', $user->name, 2)[0]."'s Account", ]); $user->ownedAccount()->save($account); $user->account()->associate($account)->save(); } /** * Create the default Location. * * @param \App\Models\User $user * @return Location */ public function createLocation(User $user) { $location = new Location([ 'owned_by' => $user->id, 'name' => explode(' ', $user->name, 2)[0]."'s Location", 'locale' => config('app.locale'), 'time_zone' => config('app.timezone') ]); //associate location to user account $user->ownedAccount->locations()->save($location); //associate new user to current location $user->switchLocation($location); return $location; } protected function createDefaultAbsentTypes(User $user, Location $location) { $newAbsentTypes = $location->absentTypes()->createMany([ [ 'title' => 'Krankheit', 'affect_vacation_times' => false, 'affect_evaluations' => true, 'evaluation_calculation_setting' => 'absent_to_target' ], [ 'title' => 'Urlaub', 'affect_vacation_times' => true, 'affect_evaluations' => true, 'evaluation_calculation_setting' => 'absent_to_target' ], [ 'title' => 'Überstundenabbau', 'affect_evaluations' => false, 'affect_vacation_times' => false ], [ 'title' => 'Wunschfrei', 'affect_evaluations' => false, 'affect_vacation_times' => false ] ]); $user->absenceTypes()->sync($newAbsentTypes); } public function createDefaultTargetHours($user) { $user->targetHours()->create([ "start_date" => Carbon::today(), "hours_per" => "week", "target_hours" => 40, "target_limited" => false, "is_mon" => true, "mon" => 8, "is_tue" => true, "tue" => 8, "is_wed" => true, "wed" => 8, "is_thu" => true, "thu" => 8, "is_fri" => true, "fri" => 8, "is_sat" => false, "sat" => 0, "is_sun" => false, "sun" => 0 ]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/Fortify/PasswordValidationRules.php
app/Actions/Fortify/PasswordValidationRules.php
<?php namespace App\Actions\Fortify; use Laravel\Fortify\Rules\Password; trait PasswordValidationRules { /** * Get the validation rules used to validate passwords. * * @return array */ protected function passwordRules() { return ['required', 'string', new Password, 'confirmed']; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/Fortify/ResetUserPassword.php
app/Actions/Fortify/ResetUserPassword.php
<?php namespace App\Actions\Fortify; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Laravel\Fortify\Contracts\ResetsUserPasswords; class ResetUserPassword implements ResetsUserPasswords { use PasswordValidationRules; /** * Validate and reset the user's forgotten password. * * @param mixed $user * @param array $input * @return void */ public function reset($user, array $input) { Validator::make($input, [ 'password' => $this->passwordRules(), ])->validate(); $user->forceFill([ 'password' => Hash::make($input['password']), ])->save(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Actions/Jetstream/DeleteUser.php
app/Actions/Jetstream/DeleteUser.php
<?php namespace App\Actions\Jetstream; use App\Models\User; use App\Contracts\DeletesAccounts; use Illuminate\Support\Facades\DB; use App\Contracts\DeletesLocations; use Laravel\Jetstream\Contracts\DeletesUsers; class DeleteUser implements DeletesUsers { /** * The account deleter implementation. * * @var \App\Contracts\DeletesAccounts */ protected $deletesAccounts; /** * The location deleter implementation. * * @var \App\Contracts\DeletesLocations */ protected $deletesLocations; /** * Create a new action instance. * * @param \App\Contracts\DeletesAccounts $deletesAccounts * @param \App\Contracts\DeletesLocations $deletesLocations * @return void */ public function __construct(DeletesAccounts $deletesAccounts, DeletesLocations $deletesLocations) { $this->deletesAccounts = $deletesAccounts; $this->deletesLocations = $deletesLocations; } /** * Delete the given user. * * @param User $user * @return void */ public function delete($user) { DB::transaction(function () use ($user) { $this->deleteLocations($user); $this->deleteAccounts($user); $user->deleteProfilePhoto(); $user->tokens->each->delete(); $user->delete(); }); } /** * Delete the accounts and account associations attached to the user. * * @param mixed $user * @return void */ protected function deleteAccounts($user) { if ($user->ownedAccount) { $this->deletesAccounts->delete($user->ownedAccount); } } /** * Delete the teams and team associations attached to the user. * * @param mixed $user * @return void */ protected function deleteLocations($user) { $user->locations()->detach(); $user->ownedLocations->each(function ($location) { $this->deletesLocations->delete($location); }); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false