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/Rules/DateFormatterRule.php
app/Rules/DateFormatterRule.php
<?php namespace App\Rules; use DateTime; use Illuminate\Contracts\Validation\Rule; class DateFormatterRule implements Rule { /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { if (! is_string($value) && ! is_numeric($value) || is_null($value)) { return false; } $format = 'd.m.Y'; $date = DateTime::createFromFormat('!'.$format, $value); return $date && $date->format($format) == $value; } /** * Get the validation error message. * * @return string */ public function message() { return __('The date format is wrong.'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Rules/InvertedNumberHasCorrectScale.php
app/Rules/InvertedNumberHasCorrectScale.php
<?php namespace App\Rules; use Brick\Math\BigDecimal; use Illuminate\Contracts\Validation\Rule; use Brick\Math\Exception\DivisionByZeroException; use Brick\Math\Exception\RoundingNecessaryException; class InvertedNumberHasCorrectScale implements Rule { protected $divisor; protected $scale; /** * Create a new rule instance. * * @return void */ public function __construct($divisor, $scale) { $this->divisor = $divisor; $this->scale = $scale; } /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { if (!$value) { return; } try { $test = BigDecimal::of($this->divisor)->dividedBy($value, $this->scale); return true; } catch (RoundingNecessaryException $ex) { return false; } catch (DivisionByZeroException $ex) { return false; } } /** * Get the validation error message. * * @return string */ public function message() { return 'Rounding issue detected. Please choose another value.'; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Rules/NumberHasCorrectScale.php
app/Rules/NumberHasCorrectScale.php
<?php namespace App\Rules; use Brick\Math\BigDecimal; use Illuminate\Contracts\Validation\Rule; use Brick\Math\Exception\DivisionByZeroException; use Brick\Math\Exception\RoundingNecessaryException; class NumberHasCorrectScale implements Rule { protected $divisor; protected $scale; /** * Create a new rule instance. * * @return void */ public function __construct($divisor, $scale) { $this->divisor = $divisor; $this->scale = $scale; } /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { if (!$value) { return; } try { BigDecimal::of($value)->dividedBy($this->divisor, $this->scale); return true; } catch (RoundingNecessaryException $ex) { return false; } catch (DivisionByZeroException $ex) { return false; } } /** * Get the validation error message. * * @return string */ public function message() { return 'Rounding issue detected. Please choose another value.'; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Rules/DateTimeFormatterRule.php
app/Rules/DateTimeFormatterRule.php
<?php namespace App\Rules; use DateTime; use Illuminate\Contracts\Validation\Rule; class DateTimeFormatterRule implements Rule { /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { if (! is_string($value) && ! is_numeric($value)) { return false; } $format = 'd.m.Y H:i'; $date = DateTime::createFromFormat('!'.$format, $value); return $date && $date->format($format) == $value; } /** * Get the validation error message. * * @return string */ public function message() { return __('The given date format is wrong.'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Collections/WeekDayCollection.php
app/Collections/WeekDayCollection.php
<?php namespace App\Collections; use App\Models\Day; use Brick\Math\BigDecimal; use Illuminate\Support\Str; use Illuminate\Support\Collection; class WeekDayCollection extends Collection { public function __construct() { $this->items = $this->getArrayableItems($this->defaultDaysArray()); } public function getDayForDate($date): Day { return $this->first(function ($value, $key) use ($date) { if (Str::ucfirst($value->day) === $date->format('D')) { return true; } }, (new Day('undefined', false, BigDecimal::zero()))); } public function serializeForDatabase(): array { return $this->flattenArray( $this->normalizedDays( $this->items, array_keys($this->items) ) ); } protected function normalizedDays($items, $keys) { return array_map( function ($value) { return [ 'is_'.$value->day => $value->state, $value->day => $value->hours ]; }, $items, $keys); } protected function flattenArray($items) { $result = []; foreach ($items as $key => $value) { $assoc = $value; foreach ($assoc as $mapKey => $mapValue) { $result[$mapKey] = $mapValue; } } return $result; } protected function defaultDaysArray() { return array_map( function ($value) { return new Day( $value['day'], $value['state'], $value['hours'] ); }, $this->defaultValues() ); } protected function defaultValues() { return [ [ 'day' => 'mon', 'state' => true, 'hours' => BigDecimal::zero() ], [ 'day' => 'tue', 'state' => true, 'hours' => BigDecimal::zero() ], [ 'day' => 'wed', 'state' => true, 'hours' => BigDecimal::zero() ], [ 'day' => 'thu', 'state' => true, 'hours' => BigDecimal::zero() ], [ 'day' => 'fri', 'state' => true, 'hours' => BigDecimal::zero() ], [ 'day' => 'sat', 'state' => false, 'hours' => BigDecimal::zero() ], [ 'day' => 'sun', 'state' => false, 'hours' => BigDecimal::zero() ] ]; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/DeletesAccounts.php
app/Contracts/DeletesAccounts.php
<?php namespace App\Contracts; interface DeletesAccounts { /** * Delete the given account. * * @param mixed $account * @return void */ public function delete($account); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/RemovesVacationEntitlements.php
app/Contracts/RemovesVacationEntitlements.php
<?php namespace App\Contracts; use App\Models\User; interface RemovesVacationEntitlements { public function remove(User $employee, $vacationEntitlementId); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/UpdatesTimeTracking.php
app/Contracts/UpdatesTimeTracking.php
<?php namespace App\Contracts; use App\Models\User; use App\Models\Location; interface UpdatesTimeTracking { /** * Validate and update the given time tracking. * * @param User $user * @param mixed $timeTrackingId * @param array $input * @param array $pauseTimes * @return void */ public function update(User $user, Location $location, int $manageTimeTrackingForId, int $timeTrackingId, array $input, array $pauseTimes); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/RemovesLocation.php
app/Contracts/RemovesLocation.php
<?php namespace App\Contracts; use App\Models\User; interface RemovesLocation { public function remove(User $employee, $removeLocationId); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/FiltersEvaluation.php
app/Contracts/FiltersEvaluation.php
<?php namespace App\Contracts; use App\Models\Absence; use App\Models\Location; use App\Models\User; interface FiltersEvaluation { public function filter(User $employee, Location $location, array $filter); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/AddsLocation.php
app/Contracts/AddsLocation.php
<?php namespace App\Contracts; use App\Models\User; use App\Models\Account; interface AddsLocation { public function add(Account $account, User $employee, array $data); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/UpdatesAbsenceType.php
app/Contracts/UpdatesAbsenceType.php
<?php namespace App\Contracts; use App\Models\AbsenceType; interface UpdatesAbsenceType { public function update(AbsenceType $absenceType, array $data, array $assignedUsers = null); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/RemovesPublicHoliday.php
app/Contracts/RemovesPublicHoliday.php
<?php namespace App\Contracts; use App\Models\Location; interface RemovesPublicHoliday { /** * Remove a public holiday. * * @param mixed $location * @param mixed $publicHolidayIdBeingRemoved * @return void */ public function remove(Location $location, $publicHolidayIdBeingRemoved); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/DeletesLocations.php
app/Contracts/DeletesLocations.php
<?php namespace App\Contracts; interface DeletesLocations { /** * Delete the given location. * * @param mixed $location * @return void */ public function delete($location); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/TransfersVacationEntitlements.php
app/Contracts/TransfersVacationEntitlements.php
<?php namespace App\Contracts; use App\Models\User; interface TransfersVacationEntitlements { /** * Used to transfer a vacation entitlement * * @param mixed $employee * @param mixed $vacationEntitlementId * @return void */ public function transfer(User $employee, $vacationEntitlementId); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/InvitesLocationMembers.php
app/Contracts/InvitesLocationMembers.php
<?php namespace App\Contracts; interface InvitesLocationMembers { /** * Invite a new location member to the given location. * * @param mixed $user * @param mixed $location * @param string $email * @return void */ public function invite($user, $location, string $email, string $role = null); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/InvitesUserToLocation.php
app/Contracts/InvitesUserToLocation.php
<?php namespace App\Contracts; interface InvitesUserToLocation { /** * Add a new team member to the given team. * * @param mixed $user * @param mixed $location * @param string $email * @return void */ public function invite($user, $location, string $email, string $role = null); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/AddsTimeTrackings.php
app/Contracts/AddsTimeTrackings.php
<?php namespace App\Contracts; use App\Models\User; use App\Models\Location; interface AddsTimeTrackings { public function add(User $user, Location $location, int $managingTimeTrackingForId, array $array, array $pauseTimes); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/RemovesTimeTracking.php
app/Contracts/RemovesTimeTracking.php
<?php namespace App\Contracts; use App\Models\User; use App\Models\Location; interface RemovesTimeTracking { public function remove(User $user, Location $location, int $removeTimeTrackingForId, $timeTrackingId); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/UpdatesLocationNames.php
app/Contracts/UpdatesLocationNames.php
<?php namespace App\Contracts; interface UpdatesLocationNames { /** * Validate and update the given location's name. * * @param mixed $user * @param mixed $location * @param array $input * @return void */ public function update($user, $location, array $input); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/ApprovesAbsence.php
app/Contracts/ApprovesAbsence.php
<?php namespace App\Contracts; use App\Models\User; use App\Models\Absence; use App\Models\Location; interface ApprovesAbsence { public function approve(User $user, Location $location, Absence $absence); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/AddsPublicHoliday.php
app/Contracts/AddsPublicHoliday.php
<?php namespace App\Contracts; use App\Models\Location; interface AddsPublicHoliday { /** * Adds a public holiday * * @param Location $location * @param array $data * @return void */ public function add(Location $location, array $data) : void; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/AddsLocationMembers.php
app/Contracts/AddsLocationMembers.php
<?php namespace App\Contracts; interface AddsLocationMembers { /** * Add a new location member to the given location. * * @param mixed $user * @param mixed $location * @param string $email * @return void */ public function add($user, $location, string $email, string $role = null); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/AddsVacationEntitlements.php
app/Contracts/AddsVacationEntitlements.php
<?php namespace App\Contracts; use App\Models\User; interface AddsVacationEntitlements { public function add(User $employee, array $array); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/AddsTargetHours.php
app/Contracts/AddsTargetHours.php
<?php namespace App\Contracts; interface AddsTargetHours { /** * Invite a new location member to the given location. * * @param mixed $user * @param mixed $targetHour * @return void */ public function add($user, $targetHour, $availbleDays); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/UpdatesEmployeeProfile.php
app/Contracts/UpdatesEmployeeProfile.php
<?php namespace App\Contracts; interface UpdatesEmployeeProfile { public function update($user, $data); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/RemovesTargetHour.php
app/Contracts/RemovesTargetHour.php
<?php namespace App\Contracts; use App\Models\User; interface RemovesTargetHour { /** * Remove target hours from employee * * @param mixed $employee * @param mixed $targetHourIdBeingRemoved * @return void */ public function remove(User $employee, $targetHourIdBeingRemoved); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/AddsDefaultRestingTime.php
app/Contracts/AddsDefaultRestingTime.php
<?php namespace App\Contracts; interface AddsDefaultRestingTime { public function add($location, array $data); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/UpdatesLocationMembersRole.php
app/Contracts/UpdatesLocationMembersRole.php
<?php namespace App\Contracts; interface 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); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/RemovesDefaultRestingTime.php
app/Contracts/RemovesDefaultRestingTime.php
<?php namespace App\Contracts; use App\Models\Location; interface RemovesDefaultRestingTime { /** * Remove a default resting time. * * @param mixed $location * @param mixed $defaultRestingTimeIdBeingRemoved * @return void */ public function remove(Location $location, $defaultRestingTimeIdBeingRemoved); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/RemovesAbsenceType.php
app/Contracts/RemovesAbsenceType.php
<?php namespace App\Contracts; use App\Models\Location; interface RemovesAbsenceType { public function remove(Location $location, $absenceTypeId); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/ImportsPublicHolidays.php
app/Contracts/ImportsPublicHolidays.php
<?php namespace App\Contracts; use App\Models\Location; interface ImportsPublicHolidays { public function import(Location $location, int $year, string $countryCode); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/AddsAbsences.php
app/Contracts/AddsAbsences.php
<?php namespace App\Contracts; use App\Models\User; use App\Models\Location; interface AddsAbsences { /** * Add a absence for user and location * * @param User $user * @param mixed $addingAbsenceForId * @param array $data * @return void */ public function add(User $user, Location $location, int $addingAbsenceForId, array $data); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/RemovesLocationMembers.php
app/Contracts/RemovesLocationMembers.php
<?php namespace App\Contracts; interface RemovesLocationMembers { /** * Update the role for the given location member. * * @param mixed $user * @param mixed $location * @param mixed $teamMember * @return void */ public function remove($user, $location, $teamMember); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/RemovesAbsence.php
app/Contracts/RemovesAbsence.php
<?php namespace App\Contracts; use App\Models\User; use App\Models\Location; interface RemovesAbsence { /** * Remove a absence. * * @param User $user * @param Location $location * @param mixed $removesAbsenceId * @return void */ public function remove(User $user, Location $location, $removesAbsenceId); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Contracts/AddsAbsenceType.php
app/Contracts/AddsAbsenceType.php
<?php namespace App\Contracts; use App\Models\Location; interface AddsAbsenceType { public function add(Location $location, array $data, array $assignedUsers = null); }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Facades/PeriodCalculator.php
app/Facades/PeriodCalculator.php
<?php namespace App\Facades; use App\Calculators\PeriodCalculator as Calculator; use Illuminate\Support\Facades\Facade; class PeriodCalculator extends Facade { public static function getFacadeAccessor() { return new Calculator(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Facades/WorkingSessionToTimeTracking.php
app/Facades/WorkingSessionToTimeTracking.php
<?php namespace App\Facades; use App\Converter\WorkingSessionToTimeTracking as WorkingSessionConverter; use Illuminate\Support\Facades\Facade; class WorkingSessionToTimeTracking extends Facade { public static function getFacadeAccessor() { return new WorkingSessionConverter(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Console/Kernel.php
app/Console/Kernel.php
<?php namespace App\Console; use App\Jobs\ExpireVacationEntitlements; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { /** * The Artisan commands provided by your application. * * @var array */ protected $commands = [ // ]; /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $schedule->call(function() { ExpireVacationEntitlements::dispatch(); })->name('expire_vacation_entitlements')->withoutOverlapping()->hourly(); $schedule->command('backup:clean')->daily()->at('17:00')->withoutOverlapping()->environments('production'); $schedule->command('backup:run')->daily()->at('21:00')->withoutOverlapping()->environments('production'); } /** * Register the commands for the application. * * @return void */ protected function commands() { $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Console/Commands/RecalculatePauseTimes.php
app/Console/Commands/RecalculatePauseTimes.php
<?php namespace App\Console\Commands; use App\Models\TimeTracking; use Illuminate\Console\Command; use App\Models\DefaultRestingTime; class RecalculatePauseTimes extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'daybreak:recalculate-pause-times'; /** * The console command description. * * @var string */ protected $description = 'Recalculate and update time tracking pause times based on given pause times and default resting times'; /** * Create a new command instance. * * @return void */ // public function __construct() // { // parent::__construct(); // } /** * Execute the console command. * * @return int */ public function handle() { TimeTracking::with(['user.defaultRestingTimes','pauseTimes'])->get()->each->updatePauseTime(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/WorkingSessionAction.php
app/Models/WorkingSessionAction.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; class WorkingSessionAction extends Model { use HasFactory; protected $casts = [ 'action_time' => 'datetime' ]; protected $fillable = [ 'working_session_id', 'action_type', 'action_time' ]; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/TimeTracking.php
app/Models/TimeTracking.php
<?php namespace App\Models; use App\Models\User; use App\Traits\HasPeriod; use Brick\Math\BigDecimal; use App\Casts\BigDecimalCast; use App\Casts\DurationCast; use App\Traits\FiltersEmployees; use App\Facades\PeriodCalculator; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; class TimeTracking extends Model { use HasFactory, HasPeriod, FiltersEmployees; protected $casts = [ 'starts_at' => 'datetime', 'ends_at' => 'datetime', 'hourly_rate' => BigDecimalCast::class, 'balance' => BigDecimalCast::class, 'min_billing_increment' => BigDecimalCast::class, 'pause_time' => DurationCast::class ]; protected $fillable = [ 'description', 'user_id', 'location_id', 'starts_at', 'ends_at', 'pause_time' ]; public function user() { return $this->belongsTo(User::class); } public function pauseTimes() { return $this->hasMany(PauseTime::class); } public function getDayAttribute() { return $this->starts_at->translatedFormat('D d.m'); } public function getTimeAttribute() { return __(":start - :end o'clock", [ 'start' => $this->starts_at->translatedFormat('H:i'), 'end' => $this->ends_at->translatedFormat('H:i') ]); } public function getDurationAttribute() { return PeriodCalculator::fromPeriod($this->period)->toHours(); } public function getPauseTimeForHumansAttribute() { return $this->pause_time->inHours(); } public function getBalanceAttribute() { return BigDecimal::of($this->duration) ->minus($this->pause_time->inHours()); } public function updatePauseTime() { $this->update([ 'pause_time' => $this->calculatePauseTime( PeriodCalculator::fromTimesArray( $this->pauseTimes()->select('starts_at','ends_at')->get() ) ) ]); } protected function calculatePauseTime($pauseTimePeriodCalculator) { if (!$pauseTimePeriodCalculator->hasPeriods()) { $workingTimeInSeconds = PeriodCalculator::fromPeriod($this->period)->toSeconds(); return optional(optional( $this->user->defaultRestingTimes()->firstWhere('min_hours','<=',$workingTimeInSeconds) )->duration)->inSeconds(); } else { return $pauseTimePeriodCalculator->toSeconds(); } } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/Account.php
app/Models/Account.php
<?php namespace App\Models; use App\Models\Location; use App\Daybreak; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; class Account extends Model { use HasFactory; protected $casts = [ 'owned_by' => 'integer' ]; public function locations() { return $this->hasMany(Location::class); } public function users() { return $this->hasMany(User::class); } public function owner() { return $this->belongsTo(User::class, 'owned_by'); } public function purge() { if (Daybreak::hasProjectBillingFeature()) { $this->projects->each->purge(); } //delete assigned locations $this->locations->each->purge(); //delete ownership $this->owner->forceFill([ 'account_id' => null ])->save(); //delete owned account $this->delete(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/Absence.php
app/Models/Absence.php
<?php namespace App\Models; use App\Models\User; use App\Models\Location; use App\Models\AbsenceType; use App\Models\AbsenceIndex; use App\Casts\BigDecimalCast; use App\Formatter\DateFormatter; use App\Traits\FiltersEmployees; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; class Absence extends Model { use HasFactory, FiltersEmployees; protected $casts = [ 'starts_at' => 'datetime', 'ends_at' => 'datetime', 'vacation_days' => BigDecimalCast::class ]; protected $fillable = [ 'location_id', 'user_id', 'absence_type_id', 'starts_at', 'ends_at', 'full_day', 'force_calc_custom_hours', 'paid_hours', 'vacation_days', 'status' ]; public function absenceType() { return $this->belongsTo(AbsenceType::class); } public function index() { return $this->hasMany(AbsenceIndex::class); } public function employee() { return $this->belongsTo(User::class, 'user_id'); } public function location() { return $this->belongsTo(Location::class, 'location_id'); } /** * Mark absence as confirmed. * * @return void */ public function markAsConfirmed() { $this->update([ 'status' => 'confirmed' ]); } /** * Mark absence as Pending. * * @return void */ public function markAsPending() { $this->update([ 'status' => 'pending' ]); } /** * Determine if the absence is confirmed * * @return bool */ public function isConfimred() { return $this->status == 'confirmed'; } public function getStatusColorAttribute() { return [ 'pending' => 'indigo', 'confirmed' => 'green' ][$this->status] ?? 'cool-gray'; } public function getStartsAtForHumansAttribute() { $dateFormatter = app(DateFormatter::class); if ($this->full_day) { return $dateFormatter->formatDateForView($this->starts_at); } return $dateFormatter->formatDateTimeForView($this->starts_at); } public function getEndsAtForHumansAttribute() { $dateFormatter = app(DateFormatter::class); if ($this->full_day) { return $dateFormatter->formatDateForView($this->ends_at); } return $dateFormatter->formatDateTimeForView($this->ends_at); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/AbsenceType.php
app/Models/AbsenceType.php
<?php namespace App\Models; use App\Models\User; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; class AbsenceType extends Model { use HasFactory; protected $casts = [ 'location_id' => 'integer', 'affect_evaluations' => 'boolean', 'affect_vacation_times' => 'boolean' ]; protected $fillable = [ 'user_id', 'title', 'affect_evaluations', 'affect_vacation_times' ]; public function users() { return $this->belongsToMany(User::class, AbsenceTypeUser::class) ->withTimestamps() ->as('users'); } public function shouldSumAbsenceHoursUpToTargetHours() { return $this->evaluation_calculation_setting === 'absent_to_target'; } public function affectsVacation() { return $this->affect_vacation_times; } public function affectsEvaluation() { return $this->affect_evaluations; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/AbsenceTypeUser.php
app/Models/AbsenceTypeUser.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Relations\Pivot; class AbsenceTypeUser extends Pivot { /** * A membership is a user assigned to a location * * @var string */ protected $table = 'absence_type_user'; /** * Indicates if the IDs are auto-incrementing. * * @var bool */ public $incrementing = true; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/DefaultRestingTimeUser.php
app/Models/DefaultRestingTimeUser.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Relations\Pivot; class DefaultRestingTimeUser extends Pivot { /** * A membership is a user assigned to a location * * @var string */ protected $table = 'default_resting_time_users'; /** * Indicates if the IDs are auto-incrementing. * * @var bool */ public $incrementing = true; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/AbsenceVacationEntitlement.php
app/Models/AbsenceVacationEntitlement.php
<?php namespace App\Models; use App\Casts\BigDecimalCast; use Illuminate\Database\Eloquent\Relations\Pivot; class AbsenceVacationEntitlement extends Pivot { protected $casts = [ 'used_days' => BigDecimalCast::class ]; /** * A membership is a user assigned to a location * * @var string */ protected $table = 'absence_vacation_entitlement'; /** * Indicates if the IDs are auto-incrementing. * * @var bool */ public $incrementing = true; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/TargetHour.php
app/Models/TargetHour.php
<?php namespace App\Models; use App\Casts\BigDecimalCast; use App\Formatter\DateFormatter; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; class TargetHour extends Model { use HasFactory; protected $casts = [ 'is_mon' => 'boolean', 'is_tue' => 'boolean', 'is_wed' => 'boolean', 'is_thu' => 'boolean', 'is_fri' => 'boolean', 'is_sat' => 'boolean', 'is_sun' => 'boolean', 'target_hours' => BigDecimalCast::class, 'mon' => BigDecimalCast::class, 'tue' => BigDecimalCast::class, 'wed' => BigDecimalCast::class, 'thu' => BigDecimalCast::class, 'fri' => BigDecimalCast::class, 'sat' => BigDecimalCast::class, 'sun' => BigDecimalCast::class, 'start_date' => 'date', 'week_days' => WeekDay::class ]; protected $fillable = [ 'is_mon', 'is_tue', 'is_wed', 'is_thu', 'is_fri', 'is_sat', 'is_sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun', 'start_date', 'week_days', 'target_hours', 'hours_per' ]; public function createTargetHourSummary() { return "{$this->target_hours} / {$this->hours_per}"; } public function getStartDateForHumansAttribute() { return app(DateFormatter::class)->formatDateForView( $this->start_date ); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/User.php
app/Models/User.php
<?php namespace App\Models; use App\Traits\HasAbsences; use App\Traits\HasAccounts; use App\Traits\HasLocations; use App\Traits\HasVacations; use App\Traits\HasEvaluation; use App\Traits\HasTargetHours; use App\Traits\HasTimeTrackings; use App\Casts\BigDecimalCast; use App\Formatter\DateFormatter; use Laravel\Sanctum\HasApiTokens; use App\Traits\HasDefaultRestingTimes; use Laravel\Jetstream\HasProfilePhoto; use Illuminate\Notifications\Notifiable; use Laravel\Fortify\TwoFactorAuthenticatable; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use App\Exceptions\NoCurrentLocationSetForUserException; class User extends Authenticatable { use HasApiTokens, HasFactory, HasProfilePhoto, HasAccounts, HasLocations, HasEvaluation, HasVacations, HasAbsences, HasTargetHours, HasTimeTrackings, HasDefaultRestingTimes, Notifiable, TwoFactorAuthenticatable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', 'date_of_employment', 'opening_overtime_balance', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', 'two_factor_recovery_codes', 'two_factor_secret' ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', 'current_location_id' => 'integer', 'account_id' => 'integer', 'date_of_employment' => 'date', 'opening_overtime_balance' => BigDecimalCast::class ]; /** * The accessors to append to the model's array form. * * @var array */ protected $appends = [ 'profile_photo_url', ]; public function hasEmail($email) { return $this->email === $email; } public function getDateOfEmploymentForHumansAttribute() { return app(DateFormatter::class) ->formatDateForView($this->date_of_employment); } public function workingSessions() { return $this->hasMany(WorkingSession::class); } public function currentWorkingSession() { if (!$this->currentLocation) { throw new NoCurrentLocationSetForUserException('Location not set for user'); } if ($this->hasWorkingSession($this->currentLocation)) { return $this->workingSessions() ->where('location_id', $this->currentLocation->id) ->latest() ->sole(); } return $this->createWorkingSession($this->currentLocation); } protected function createWorkingSession(Location $location) { return $this->workingSessions()->create([ 'location_id' => $location->id ]); } protected function hasWorkingSession(Location $location) { return $this->workingSessions() ->where('location_id', $location->id) ->exists(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/AbsenceIndex.php
app/Models/AbsenceIndex.php
<?php namespace App\Models; use App\Models\User; use App\Models\Absence; use App\Casts\BigDecimalCast; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; class AbsenceIndex extends Model { use HasFactory; protected $fillable = [ 'date', 'hours', 'absence_type_id', 'user_id', 'location_id' ]; protected $casts = [ 'date' => 'date', 'hours' => BigDecimalCast::class ]; protected $table = 'absence_index'; public function absence() { return $this->belongsTo(Absence::class); } public function absenceType() { return $this->belongsTo(AbsenceType::class); } public function user() { return $this->belongsTo(User::class); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/VacationEntitlementTransfer.php
app/Models/VacationEntitlementTransfer.php
<?php namespace App\Models; use App\Casts\BigDecimalCast; use Illuminate\Database\Eloquent\Relations\Pivot; class VacationEntitlementTransfer extends Pivot { protected $casts = [ 'days' => BigDecimalCast::class ]; /** * @var string */ protected $table = 'vacation_entitlements_transfer'; /** * Indicates if the IDs are auto-incrementing. * * @var bool */ public $incrementing = true; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/WorkingSession.php
app/Models/WorkingSession.php
<?php namespace App\Models; use App\Models\User; use App\Models\Location; use Spatie\ModelStates\HasStates; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; use App\StateMachine\WorkingSession\Places\WorkingSessionState; class WorkingSession extends Model { use HasFactory; use HasStates; protected $fillable = [ 'user_id', 'location_id', 'status' ]; protected $casts = [ 'status' => WorkingSessionState::class ]; public function actions() { return $this->hasMany(WorkingSessionAction::class); } public function user() { return $this->belongsTo(User::class); } public function location() { return $this->belongsTo(Location::class); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/Membership.php
app/Models/Membership.php
<?php namespace App\Models; use Laravel\Jetstream\Membership as JetstreamMembership; class Membership extends JetstreamMembership { /** * A membership is a user assigned to a location * * @var string */ protected $table = 'location_user'; /** * Indicates if the IDs are auto-incrementing. * * @var bool */ public $incrementing = true; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/Day.php
app/Models/Day.php
<?php namespace App\Models; use ArrayAccess; use Brick\Math\BigDecimal; class Day implements ArrayAccess { public $day; public $state; public $hours; public function __construct(string $day, bool $state, BigDecimal $hours) { $this->day = $day; $this->state = $state; $this->hours = $hours; } public function toArray() { return array ( 'day' => $this->day, 'state' => $this->state, 'hours' => $this->hours, ); } public function offsetExists($offset) { return array_key_exists($offset, $this->toArray()); } public function offsetGet($offset) { return $this->toArray()[$offset]; } public function offsetSet($offset, $value) { $this->toArray()[$offset] = $value; } public function offsetUnset($offset) { unset($this->toArray()[$offset]); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/Duration.php
app/Models/Duration.php
<?php namespace App\Models; use Brick\Math\BigDecimal; use Brick\Math\RoundingMode; class Duration { /** * Holds the internal duration represenation in seconds * * @var BigDecimal */ protected $seconds; public function __construct(int $seconds) { $this->seconds = BigDecimal::of($seconds); } public function inSeconds() { return $this->seconds; } public function inMinutes() { return $this->seconds->dividedBy(60, 2, RoundingMode::HALF_EVEN); } public function inHours() { return $this->inMinutes()->dividedBy(60, 2, RoundingMode::HALF_EVEN); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/VacationEntitlement.php
app/Models/VacationEntitlement.php
<?php namespace App\Models; use App\Models\Absence; use App\Casts\BigDecimalCast; use App\Formatter\DateFormatter; use Illuminate\Database\Eloquent\Model; use App\Models\AbsenceVacationEntitlement; use App\Models\VacationEntitlementTransfer; use Brick\Math\BigDecimal; use Illuminate\Validation\ValidationException; use Illuminate\Database\Eloquent\Factories\HasFactory; class VacationEntitlement extends Model { use HasFactory; protected $casts = [ 'starts_at' => 'date', 'ends_at' => 'date', 'days' => BigDecimalCast::class, 'transfer_remaining' => 'boolean', 'expires' => 'boolean', 'end_of_transfer_period' => 'date' ]; protected $fillable = [ 'name', 'starts_at', 'ends_at', 'days', 'expires', 'transfer_remaining', 'end_of_transfer_period', 'transferred_days', 'status', //expires, does_not_expire, used, expired ]; public function getStartsAtForHumansAttribute() { return app(DateFormatter::class)->formatDateForView( $this->starts_at ); } public function getEndsAtForHumansAttribute() { return app(DateFormatter::class)->formatDateForView( $this->ends_at ); } public function getUsedDaysAttribute() { return $this->usedVacationDays->sumBigDecimals( fn ($item) => $item->usedVacationDays->used_days ); } public function hasEnoughUnusedVacationDays($days) { return $this->used_days ->plus($days) ->isLessThanOrEqualTo($this->available_days); } public function usedVacationDays() { return $this->belongsToMany(Absence::class, AbsenceVacationEntitlement::class) ->as('usedVacationDays') ->withPivot('used_days') ->withTimestamps(); } public function scopeShouldExpire($query) { $today = now()->startOfDay(); return $query ->whereIn('status', ['expires']) ->whereNotIn('status', ['used', 'does_not_expire','expired']) ->where('expires', 1) ->where('ends_at','<=',$today); } public function isExpired() { return $this->status === 'expired'; } public function notExpired() { return $this->status != 'expired'; } public function expire() { return $this->update([ 'status' => 'expired' ]); } /** * Can be transferred if not yet transferred and if enabled * * @return boolean */ public function canBeTransferred() { return !$this->transferVacationDays()->exists() && $this->transfer_remaining; } public function transferVacationDays() { return $this->belongsToMany( VacationEntitlement::class, 'vacation_entitlements_transfer', 'transferred_from_id', 'transferred_to_id' ) ->using(VacationEntitlementTransfer::class) ->as('transfer') ->withPivot('days') ->withTimestamps(); } public function transferredVacationDays() { return $this->belongsToMany( VacationEntitlement::class, 'vacation_entitlements_transfer', 'transferred_to_id', 'transferred_from_id' ) ->using(VacationEntitlementTransfer::class) ->as('transferred') ->withPivot('days') ->withTimestamps(); } public function daysTransferrable() { $daysTransferrable = $this->available_days->minus($this->used_days); if ($daysTransferrable->isNegativeOrZero()) { return BigDecimal::zero(); } return $daysTransferrable; } public function useVacationDays(Absence $absence) { if (!$absence->absenceType->affectsVacation()) { return; } if ($this->isUsed() || $this->isExpired()) { throw ValidationException::withMessages([ 'error' => [__('Vacation entitlement has wrong status.')], ]); } tap($this, fn($model) => $model->usedVacationDays()->attach($absence->id, [ 'used_days' => $absence->vacation_days ]))->load('usedVacationDays'); if ($this->used_days->isGreaterThanOrEqualTo($this->available_days)) { $this->markAsUsed(); } } public function markAsUsed() { $this->update([ 'status' => 'used' ]); } public function isUsed() { return $this->status === 'used'; } public function isTransferred() { return $this->transferVacationDays()->exists(); } public function scopeNotExpired($query) { return $query->whereNotIn('status', ['expired']); } public function scopeNotUsed($query) { return $query->whereNotIn('status', ['used']); } public function getStatusColorAttribute() { return [ 'does_not_expire' => 'green', 'expires' => 'indigo', 'expired' => 'red', 'used' => 'red' ][$this->status] ?? 'cool-gray'; } public function getTransferredDaysAttribute() { return $this->transferredVacationDays->sumBigDecimals( fn($pivot) => $pivot->transferred->days ); } public function getTransferDaysAttribute() { return $this->transferVacationDays->sumBigDecimals( fn($pivot) => $pivot->transfer->days ); } public function getAvailableDaysAttribute() { return $this->days->plus($this->transferred_days); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/Location.php
app/Models/Location.php
<?php namespace App\Models; use App\Models\User; use App\Models\Absence; use App\Models\AbsenceType; use App\Models\TimeTracking; use App\Models\PublicHoliday; use Laravel\Jetstream\Jetstream; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; class Location extends Model { protected $casts = [ 'owned_by' => 'integer' ]; protected $fillable = [ 'account_id', 'owned_by', 'name' ]; use HasFactory; public function owner() { return $this->belongsTo(User::class, 'owned_by'); } public function account() { return $this->belongsTo(Account::class); } /** * Get all of the team's users including its owner. * * @return \Illuminate\Support\Collection */ public function allUsers() { return $this->users->merge([$this->owner]); } /** * Get all of the users that belong to the team. */ public function users() { return $this->belongsToMany(Jetstream::userModel(), Jetstream::membershipModel()) ->withPivot('role') ->withTimestamps() ->as('membership'); } public function timeTrackings() { return $this->hasMany(TimeTracking::class); } public function absences() { return $this->hasMany(Absence::class); } public function absentTypes() { return $this->hasMany(AbsenceType::class); } public function defaultRestingTimes() { return $this->hasMany(DefaultRestingTime::class); } public function absenceTypeById($id) { return $this->absentTypes()->findOrFail($id); } public function absentTypesToBeAssignedToNewUsers() { return $this->hasMany(AbsenceType::class)->where('assign_new_users', true); } public function publicHolidays() { return $this->hasMany(PublicHoliday::class)->orderBy('day','DESC'); } public function publicHolidayForDate($date) { return $this->publicHolidays()->firstWhere('day', $date); } /** * Determine if the given user belongs to the team. * * @param \App\Models\User $user * @return bool */ public function hasUser($user) { return $this->users->contains($user) || $user->ownsLocation($this); } /** * Determine if the given email address belongs to a user on the team. * * @param string $email * @return bool */ public function hasUserWithEmail(string $email) { return $this->allUsers()->contains(function ($user) use ($email) { return $user->email === $email; }); } /** * Determine if the given user has the given permission on the team. * * @param \App\Models\User $user * @param string $permission * @return bool */ public function userHasPermission($user, $permission) { return $user->hasLocationPermission($this, $permission); } /** * Get all of the pending user invitations for the team. */ public function locationInvitations() { return $this->hasMany(LocationInvitation::class); } /** * Remove the given user from the team. * * @param \App\Models\User $user * @return void */ public function removeUser($user) { if ($user->current_location_id === $this->id) { $user->forceFill([ 'current_location_id' => null, ])->save(); } $this->users()->detach($user); } public function workingSessions() { return $this->hasMany(WorkingSession::class); } /** * Purge all of the location's resources. * * @return void */ public function purge() { $this->absentTypes->each->delete(); $this->publicHolidays->each->delete(); $this->owner()->where('current_location_id', $this->id) ->update(['current_location_id' => null]); $this->users()->where('current_location_id', $this->id) ->update(['current_location_id' => null]); $this->users()->detach(); $this->delete(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/DefaultRestingTime.php
app/Models/DefaultRestingTime.php
<?php namespace App\Models; use App\Casts\DurationCast; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; class DefaultRestingTime extends Model { use HasFactory; protected $casts = [ 'min_hours' => DurationCast::class, 'duration' => DurationCast::class ]; protected $fillable = [ 'min_hours', 'duration', 'location_id' ]; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/WeekDay.php
app/Models/WeekDay.php
<?php namespace App\Models; use App\Casts\WeekDayCast; use Illuminate\Contracts\Database\Eloquent\Castable; class WeekDay implements Castable { public static function castUsing(array $arguments) { return WeekDayCast::class; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/PublicHoliday.php
app/Models/PublicHoliday.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class PublicHoliday extends Model { use HasFactory; protected $dates = ['day']; protected $fillable = [ 'title', 'day', 'public_holiday_half_day', 'location_id' ]; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/VacationBan.php
app/Models/VacationBan.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class VacationBan extends Model { use HasFactory; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/LocationInvitation.php
app/Models/LocationInvitation.php
<?php namespace App\Models; use App\Models\Location; use Illuminate\Database\Eloquent\Model; class LocationInvitation extends Model { /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'email', 'role', ]; /** * Get the team that the invitation belongs to. */ public function location() { return $this->belongsTo(Location::class); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Models/PauseTime.php
app/Models/PauseTime.php
<?php namespace App\Models; use App\Models\TimeTracking; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; class PauseTime extends Model { use HasFactory; protected $casts = ['starts_at' => 'datetime', 'ends_at' => 'datetime']; protected $fillable = ['starts_at', 'ends_at']; public function timeTracking() { return $this->belongsTo(TimeTracking::class); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Calculators/PeriodCalculator.php
app/Calculators/PeriodCalculator.php
<?php namespace App\Calculators; use Carbon\CarbonPeriod; use Brick\Math\BigDecimal; use Carbon\CarbonInterval; use Carbon\CarbonImmutable; use Illuminate\Support\Arr; use Brick\Math\RoundingMode; use Illuminate\Support\Collection; class PeriodCalculator { /** * Holds array of period instances * * @var Collection */ public $periods; public function fromPeriod(CarbonPeriod $period) { $this->periods = collect([$period]); return $this; } public function fromTimesArray($timesArray) { $periods = []; foreach ($timesArray as $period) { if (!isset($period['starts_at']) || !isset($period['ends_at'])) { throw new \Exception("Not a valid times array."); } $period = new CarbonPeriod( new CarbonImmutable($period['starts_at']), CarbonInterval::minutes('1'), new CarbonImmutable($period['ends_at']) ); $periods[] = $period; } $this->periods = collect($periods); return $this; } public function toHours() : BigDecimal { $hours = BigDecimal::zero(); foreach ($this->periods as $period) { $hours = $hours->plus( BigDecimal::of($period->start->diffInMinutes($period->end)) ->dividedBy(60, 2, RoundingMode::HALF_EVEN) ); } return $hours; } public function toMinutes() : BigDecimal { $minutes = BigDecimal::zero(); foreach ($this->periods as $period) { $minutes = $minutes->plus( BigDecimal::of($period->start->diffInMinutes($period->end)) ); } return $minutes; } public function toSeconds() : BigDecimal { $seconds = BigDecimal::zero(); foreach ($this->periods as $period) { $seconds = $seconds->plus( BigDecimal::of($period->start->diffInSeconds($period->end)) ); } return $seconds; } public function hasPeriods() : bool { return count($this->periods) ? true : false; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Providers/Features.php
app/Providers/Features.php
<?php namespace App\Providers; class Features { /** * Determine if the given feature is enabled. * * @param string $feature * @return bool */ public static function enabled(string $feature) { return in_array($feature, config('app.features', [])); } public static function projectBilling() { return 'billing'; } public static function employeePayroll() { return 'payroll'; } public static function caldav() { return 'caldav'; } /** * Determine if the application has project billing enabled. * * @return bool */ public static function hasProjectBillingFeature() { return static::enabled(static::projectBilling()); } /** * Determine if the application has payroll enabled. * * @return bool */ public static function hasEmployeePayrollFeature() { return static::enabled(static::employeePayroll()); } public static function hasCaldavFeature() { return static::enabled(static::caldav()); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Providers/FortifyServiceProvider.php
app/Providers/FortifyServiceProvider.php
<?php namespace App\Providers; use App\Models\User; use Illuminate\Http\Request; use Laravel\Fortify\Fortify; use Illuminate\Support\Facades\Hash; use App\Actions\Fortify\CreateNewUser; use Illuminate\Support\ServiceProvider; use Illuminate\Cache\RateLimiting\Limit; use App\Actions\Fortify\ResetUserPassword; use App\Actions\Fortify\UpdateUserPassword; use Illuminate\Support\Facades\RateLimiter; use App\Actions\Fortify\UpdateUserProfileInformation; class FortifyServiceProvider extends ServiceProvider { /** * Register any application services. * * @return void */ public function register() { // } /** * Bootstrap any application services. * * @return void */ public function boot() { Fortify::createUsersUsing(CreateNewUser::class); Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class); Fortify::updateUserPasswordsUsing(UpdateUserPassword::class); Fortify::resetUserPasswordsUsing(ResetUserPassword::class); Fortify::authenticateUsing(function (Request $request) { $user = User::where('email', $request->email)->first(); if ($user && Hash::check($request->password, $user->password) && $user->currentLocation()->exists() ) { return $user; } }); RateLimiter::for('login', function (Request $request) { return Limit::perMinute(5)->by($request->email.$request->ip()); }); RateLimiter::for('two-factor', function (Request $request) { return Limit::perMinute(5)->by($request->session()->get('login.id')); }); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Providers/BroadcastServiceProvider.php
app/Providers/BroadcastServiceProvider.php
<?php namespace App\Providers; use Illuminate\Support\Facades\Broadcast; use Illuminate\Support\ServiceProvider; class BroadcastServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { Broadcast::routes(); require base_path('routes/channels.php'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Providers/RouteServiceProvider.php
app/Providers/RouteServiceProvider.php
<?php namespace App\Providers; use Illuminate\Cache\RateLimiting\Limit; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Http\Request; use Illuminate\Support\Facades\RateLimiter; use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { /** * The path to the "home" route for your application. * * This is used by Laravel authentication to redirect users after login. * * @var string */ public const HOME = '/time-tracking'; /** * Define your route model bindings, pattern filters, etc. * * @return void */ public function boot() { $this->configureRateLimiting(); $this->routes(function () { Route::prefix('api') ->middleware('api') ->group(base_path('routes/api.php')); Route::middleware('web') ->group(base_path('routes/web.php')); }); } /** * Configure the rate limiters for the application. * * @return void */ protected function configureRateLimiting() { RateLimiter::for('api', function (Request $request) { return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); }); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Providers/EventServiceProvider.php
app/Providers/EventServiceProvider.php
<?php namespace App\Providers; use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Event; class EventServiceProvider extends ServiceProvider { /** * The event listener mappings for the application. * * @var array */ protected $listen = [ Registered::class => [ SendEmailVerificationNotification::class, ], ]; /** * Register any events for your application. * * @return void */ public function boot() { // } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Providers/AppServiceProvider.php
app/Providers/AppServiceProvider.php
<?php namespace App\Providers; use App\Daybreak; use Carbon\Carbon; use Livewire\Livewire; use Brick\Math\BigDecimal; use App\Actions\AddAbsence; use Illuminate\Support\Arr; use App\Actions\AddLocation; use App\Actions\AddTargetHour; use App\Actions\DeleteAccount; use App\Actions\RemoveAbsence; use App\Actions\AddAbsenceType; use App\Actions\DeleteLocation; use App\Actions\RemoveLocation; use App\Actions\AddTimeTracking; use App\Actions\ApproveAbscence; use App\Actions\AddPublicHoliday; use App\Actions\FilterEvaluation; use App\Actions\RemoveTargetHour; use App\Actions\AddLocationMember; use App\Actions\RemoveAbsenceType; use App\Actions\UpdateAbsenceType; use Illuminate\Support\Collection; use App\Actions\RemoveTimeTracking; use App\Actions\UpdateLocationName; use App\Actions\UpdateTimeTracking; use App\Actions\RemovePublicHoliday; use App\Actions\ImportPublicHolidays; use App\Actions\InviteLocationMember; use App\Actions\RemoveLocationMember; use Illuminate\Support\Facades\Blade; use App\Actions\AddDefaultRestingTime; use App\Actions\UpdateEmployeeProfile; use App\Formatter\GermanDateFormatter; use App\Actions\AddVacationEntitlement; use Illuminate\Support\ServiceProvider; use App\Actions\RemoveDefaultRestingTime; use App\Actions\UpdateLocationMemberRole; use App\Http\Livewire\Locations\Calendar; use Illuminate\Database\Eloquent\Builder; use App\Actions\RemoveVacationEntitlement; use Carbon\Exceptions\InvalidTypeException; use App\Actions\TransferVacationEntitlement; use Illuminate\View\Compilers\BladeCompiler; class AppServiceProvider extends ServiceProvider { /** * Register any application services. * * @return void */ public function register() { $this->registerLivewireComponents(); } /** * Bootstrap any application services. * * @return void */ public function boot() { Carbon::setlocale(config('app.locale')); $this->loadViewsFrom(__DIR__.'/../../resources/views', 'daybreak'); $this->configureComponents(); $this->registerCollectionMacros(); $this->registerBuilderMacros(); Daybreak::addLocationMembersUsing(AddLocationMember::class); Daybreak::updateLocationNamesUsing(UpdateLocationName::class); Daybreak::inviteLocationMembersUsing(InviteLocationMember::class); Daybreak::updatesLocationMembersRoleUsing(UpdateLocationMemberRole::class); Daybreak::removesLocationMembersUsing(RemoveLocationMember::class); Daybreak::addsTargetHoursUsing(AddTargetHour::class); Daybreak::addsAbsencesUsing(AddAbsence::class); Daybreak::formatsDatesUsing(GermanDateFormatter::class); Daybreak::addsTimeTrackingsUsing(AddTimeTracking::class); Daybreak::approvesAbsenceUsing(ApproveAbscence::class); Daybreak::filtersEvaluationUsing(FilterEvaluation::class); Daybreak::removesTimeTrackingUsing(RemoveTimeTracking::class); Daybreak::removesAbsenceUsing(RemoveAbsence::class); Daybreak::removesAbsenceTypeUsing(RemoveAbsenceType::class); Daybreak::addsAbsenceTypeUsing(AddAbsenceType::class); Daybreak::removesTargetHourUsing(RemoveTargetHour::class); Daybreak::addsVacationEntitlementUsing(AddVacationEntitlement::class); Daybreak::transfersVacationEntitlementUsing(TransferVacationEntitlement::class); Daybreak::removesVacationEntitlementUsing(RemoveVacationEntitlement::class); Daybreak::deletesAccountsUsing(DeleteAccount::class); Daybreak::deletesLocationsUsing(DeleteLocation::class); Daybreak::removesLocationsUsing(RemoveLocation::class); Daybreak::addsLocationsUsing(AddLocation::class); Daybreak::updatesTimeTrackingsUsing(UpdateTimeTracking::class); Daybreak::updatesAbsenceTypeUsing(UpdateAbsenceType::class); Daybreak::updatesEmployeeProfileUsing(UpdateEmployeeProfile::class); Daybreak::importsPublicHolidaysUsing(ImportPublicHolidays::class); Daybreak::addsPublicHolidayUsing(AddPublicHoliday::class); Daybreak::removesPublicHolidayUsing(RemovePublicHoliday::class); Daybreak::addsDefaultRestingTimeUsing(AddDefaultRestingTime::class); Daybreak::removesDefaultRestingTimeUsing(RemoveDefaultRestingTime::class); Collection::macro('mapToMultipleSelect', function () { /** * @var Collection $this */ return $this->map( function ($value, $key) { return [ 'id' => $key, 'title' => $value, ]; })->values()->toArray(); }); Collection::macro('filterMultipleSelect', function ($callback) { /** * @var Collection $this */ return $this->filter(function ($item) use ($callback) { return call_user_func($callback, $item); })->values()->toArray(); }); } /** * Configure the Daybreak Blade components. * * @return void */ protected function configureComponents() { $this->callAfterResolving(BladeCompiler::class, function () { $this->registerComponent('locations.switchable-location'); }); } public function registerLivewireComponents() { Livewire::component('location-calendar', Calendar::class); } /** * Register the given component. * * @param string $component * @return void */ protected function registerComponent(string $component) { Blade::component('daybreak::'.$component, 'daybreak-'. str_replace('.','-',$component) ); } public function registerBuilderMacros() { Builder::macro('whereLike', function ($attributes, string $searchTerm = null) { if (!$searchTerm) { return $this; } $this->where(function (Builder $query) use ($attributes, $searchTerm) { foreach (Arr::wrap($attributes) as $attribute) { $query->when( str_contains($attribute, '.'), function (Builder $query) use ($attribute, $searchTerm) { [$relationName, $relationAttribute] = explode('.', $attribute); $query->orWhereHas($relationName, function (Builder $query) use ($relationAttribute, $searchTerm) { $query->where($relationAttribute, 'LIKE', "%{$searchTerm}%"); }); }, function (Builder $query) use ($attribute, $searchTerm) { $query->orWhere($attribute, 'LIKE', "%{$searchTerm}%"); } ); } }); return $this; }); } public function registerCollectionMacros() { Collection::macro('sumBigDecimals', function ($callback = null) { /** * @var Collection $this */ $callback = is_null($callback) ? $this->identity() : $this->valueRetriever($callback); return $this->reduce( function (BigDecimal $carry, $item) use ($callback) { $value = $callback($item); if (!($value instanceof BigDecimal)) { throw new InvalidTypeException("Passed value should be of type BigDecimal"); } return $carry->plus($value); }, BigDecimal::zero() ); }); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Providers/AuthServiceProvider.php
app/Providers/AuthServiceProvider.php
<?php namespace App\Providers; use App\Models\Team; use App\Models\Account; use App\Policies\TeamPolicy; use App\Policies\AccountPolicy; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider { /** * The policy mappings for the application. * * @var array */ protected $policies = [ Account::class => AccountPolicy::class ]; /** * Register any authentication / authorization services. * * @return void */ public function boot() { $this->registerPolicies(); // } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Providers/JetstreamServiceProvider.php
app/Providers/JetstreamServiceProvider.php
<?php namespace App\Providers; use App\Actions\Jetstream\DeleteUser; use Illuminate\Support\ServiceProvider; use Laravel\Jetstream\Jetstream; class JetstreamServiceProvider extends ServiceProvider { /** * Register any application services. * * @return void */ public function register() { // } /** * Bootstrap any application services. * * @return void */ public function boot() { $this->configurePermissions(); Jetstream::deleteUsersUsing(DeleteUser::class); } /** * Configure the roles and permissions that are available within the application. * * @return void */ protected function configurePermissions() { Jetstream::role('admin', __('Location administrator'), [ 'updateLocation', 'addLocationMember', 'updateLocationMember', 'removeLocationMember', 'addLocationAbsentType', 'manageTimeTracking', 'updateTimeTracking', 'manageAbsence', 'approveAbsence', 'filterAbsences', 'addDefaultRestingTime', 'viewAnyTimeTracking', 'filterTimeTracking', 'assignProjects', 'editLocations', 'switchReportEmployee', ])->description(__('Location administrators can perform updates on a location.')); Jetstream::role('employee', __('Employee'), [ ])->description(__('Employees can create new working hours.')); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Holiday/Client.php
app/Holiday/Client.php
<?php namespace App\Holiday; use Illuminate\Support\Facades\Http; class Client { public $config; public function __construct(array $config) { $this->config = $config; } public function request($countryCode, $year) { $uri = "?jahr=$year&nur_land=$countryCode"; $response = Http::get($this->config['base_url'].$uri); if ($response->failed()) { throw new \Exception(__("Sth. went wrong.")); } return new Holidays($response->json()); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Holiday/Holidays.php
app/Holiday/Holidays.php
<?php namespace App\Holiday; class Holidays { protected $response; public function __construct(array $response) { $this->response = $response; } public function toCollection() { return collect($this->response)->map(function ($item, $key) { return new Holiday($key, $item); }); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Holiday/Holiday.php
app/Holiday/Holiday.php
<?php namespace App\Holiday; use Illuminate\Contracts\Support\Arrayable; class Holiday implements Arrayable { protected $title; protected $meta; public function __construct(string $title, array $meta) { $this->title = $title; $this->meta = $meta; } public function toArray() { return [ 'title' => $this->title, 'day' => $this->meta['datum'] ]; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Report/ReportRowBuilder.php
app/Report/ReportRowBuilder.php
<?php namespace App\Report; use App\Models\User; use App\Models\Location; class ReportRowBuilder { /** * The current day, which should be inspected * @var DateTime */ public $date; public $employee; public $location; /** * @var Row */ public $previousRow; public $startingBalance; public function withPreviousRow($previousRow) { $this->previousRow = $previousRow; return $this; } public function withStartingBalance($startingBalance) { $this->startingBalance = $startingBalance; return $this; } public function __construct($date, User $employee, Location $location) { $this->date = $date; $this->employee = $employee; $this->location = $location; } public function build() { return (new ReportRow($this))->generate(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Report/StartBalanceRowFacade.php
app/Report/StartBalanceRowFacade.php
<?php namespace App\Report; use Illuminate\Support\Facades\Facade; class StartBalanceRowFacade extends Facade { protected static function getFacadeAccessor() { return StartBalanceRowBuilder::class; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Report/ReportRow.php
app/Report/ReportRow.php
<?php namespace App\Report; use Brick\Math\BigDecimal; use Brick\Math\RoundingMode; use Carbon\Carbon; class ReportRow { /** * @var Row */ protected $previousRow; /** * The current day * * @var Carbon */ public $date; protected $employee; protected $balance; protected $plannedHours; protected $workingHours; protected $diff; protected $startingBalance; protected $absentHours; protected $absentHoursCollection; public function __construct(ReportRowBuilder $builder) { $this->previousRow = $builder->previousRow; $this->date = $builder->date; $this->employee = $builder->employee; $this->location = $builder->location; $this->startingBalance = $builder->startingBalance; $this->absentHoursCollection = collect(); } public function name() : string { return $this->employee->name; } public function label() : string { return $this->date->translatedFormat('D d.m.Y'); } public function labelColor() : string { return [ 'Sat' => 'bg-gray-50', 'Sun' => 'bg-gray-50' ][$this->date->shortEnglishDayOfWeek] ?? ''; } public function date() : Carbon { return $this->date; } protected function calculateRowBalance() { if (is_null($this->previousRow)) { $this->balance = BigDecimal::zero() ->plus($this->diff) ->plus($this->startingBalance ?: BigDecimal::zero()); } else { $this->balance = $this->previousRow ->balance() ->plus($this->diff) ->plus($this->startingBalance ?: BigDecimal::zero()); } } protected function calculateTargetHours() { $day = $this->employee->getTargetHour($this->date) ->week_days->getDayForDate($this->date); $this->plannedHours = $day->state ? $day->hours : BigDecimal::zero(); } protected function calculateWorkingHours() { $this->workingHours = $this->employee->workingHoursForDate($this->date) ?: BigDecimal::zero(); } protected function calculateAbsentHours() { $this->absentHoursCollection = $this->employee->absentHoursForDate($this->date)->get(); $publicHoliday = $this->publicHoliday(); if (!$publicHoliday) { $this->absentHours = $this->absentHoursCollection->sumBigDecimals('hours'); } else { if ($publicHoliday->public_holiday_half_day) { $this->absentHours = $this->plannedHours() ->divideBy('2', 2, RoundingMode::HALF_EVEN); } $this->absentHours = $this->plannedHours(); } } protected function calculateDifference() { $this->diff = $this->workingHours ->minus($this->plannedHours) ->plus($this->absentHours); } public function generate() : self { $this->calculateTargetHours(); $this->calculateWorkingHours(); $this->calculateAbsentHours(); $this->calculateDifference(); $this->calculateRowBalance(); return $this; } /** * Zeiterfassungen, also gearbeitete Stunden in der Vergangenheit */ public function workingHours() { return $this->workingHours; } /** * Anzahl der Stunden, die der Mitarbeiter pro Tag arbeiten soll */ public function plannedHours() { return $this->plannedHours; } protected function publicHoliday() { return $this->location->publicHolidayForDate($this->date); } public function publicHolidayLabel() { $publicHoliday = $this->publicHoliday(); if ($publicHoliday) { return $publicHoliday->title; } return ''; } /** * Ist - Soll + Abwesend */ public function diff() { return $this->diff; } public function balance(): BigDecimal { return $this->balance; } public function absentHours() { return $this->absentHours; } public function absentHoursCollection() { return $this->absentHoursCollection; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Report/StartBalanceRowBuilder.php
app/Report/StartBalanceRowBuilder.php
<?php namespace App\Report; use Brick\Math\BigDecimal; class StartBalanceRowBuilder { public $date; public $balance; public function fromRow(ReportRow $row) { $this->date = $row->date; $this->balance = $row->balance(); return new StartBalanceRow($this); } public function fromStartingBalance(BigDecimal $startingBalance) { $this->balance = $startingBalance; return new StartBalanceRow($this); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Report/ReportBuilder.php
app/Report/ReportBuilder.php
<?php namespace App\Report; use Carbon\Carbon; use App\Models\User; use App\Models\Location; use Carbon\CarbonPeriod; class ReportBuilder { public $employee; public $location; public $fromDate; public $toDate; public function __construct(User $employee, Location $location, Carbon $fromDate, Carbon $toDate) { $this->employee = $employee; $this->location = $location; $this->fromDate = $fromDate->copy()->startOfDay()->toImmutable(); $this->toDate = $toDate; $this->period = new CarbonPeriod( $this->beginAt(), $toDate ); } /** * The report period always starts with the date of the employment of the employee * * @return void */ protected function beginAt() { return $this->employee->date_of_employment ?? $this->fromDate; } public function build() { return (new Report($this)) ->generate(); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Report/StartBalanceRow.php
app/Report/StartBalanceRow.php
<?php namespace App\Report; use Brick\Math\BigDecimal; use Carbon\Carbon; class StartBalanceRow { public $balance; public function __construct(StartBalanceRowBuilder $builder) { $this->balance = $builder->balance; } public function balance() : BigDecimal { return $this->balance; } public function date() : Carbon { return $this->date; } public function label() : string { return __("Starting Balance"); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Report/Report.php
app/Report/Report.php
<?php namespace App\Report; use Carbon\Carbon; use App\Report\StartBalanceRowFacade as StartBalanceRow; use Brick\Math\BigDecimal; class Report { public $startRow; public $reportRows; protected $employee; protected $location; protected $period; /** * Date when to memorize the StartBalanceRow * @var Carbon */ public $fromDate; public function __construct(ReportBuilder $builder) { $this->employee = $builder->employee; $this->location = $builder->location; $this->fromDate = $builder->fromDate; $this->period = $builder->period; $this->reportRows = collect(); } protected function currentDateIsStartDate($current) { return $this->fromDate->isSameDay($current); } public function generate() { $previousRow = null; while ($this->period->valid()) { $builder = new ReportRowBuilder( $this->period->current(), $this->employee, $this->location ); if ($this->currentDateIsStartDate($this->period->current())) { $builder = $builder->withStartingBalance( $this->employee->opening_overtime_balance ?? 0 ); } if ($previousRow) { $builder = $builder->withPreviousRow($previousRow); } $row = $builder->build(); if ($this->currentDateIsStartDate($this->period->current())) { $this->memoizeStartRow($row); } if ($this->period->current()->gte($this->fromDate)) { $this->reportRows->add($row); } $previousRow = $row; $this->period->next(); } $this->period->rewind(); return $this; } public function getTotalBalance(): BigDecimal { return $this->reportRows->last()->balance(); } /** * Memoizes the starting Row of the report */ protected function memoizeStartRow($row) { if ($this->fromDate->isSameDay($this->employee->date_of_employment)) { $this->startRow = StartBalanceRow::fromStartingBalance( $this->employee->opening_overtime_balance ); } else { $this->startRow = StartBalanceRow::fromRow($row); } } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Converter/WorkingSessionToTimeTracking.php
app/Converter/WorkingSessionToTimeTracking.php
<?php namespace App\Converter; use Illuminate\Database\Eloquent\Collection; class WorkingSessionToTimeTracking { public $startsAt; public $endsAt; public $pauseTimes; public function fromCollection(Collection $collect) { $this->startsAt = $collect->firstWhere('action_type', 'starts_at')->action_time; $this->endsAt = $collect->firstWhere('action_type', 'ends_at')->action_time; $pauseCollection = $collect->reject(function ($value, $key) { return in_array( $value->action_type, ['starts_at', 'ends_at'] ); })->sortBy('action_time', SORT_ASC); $pauseArray = []; $pauseCollection->each(function ($pause) use (&$pauseArray) { if ($pause->action_type === 'pause_starts_at') { $pauseArray[] = [ 'starts_at' => $pause->action_time ]; } elseif ($pause->action_type === 'pause_ends_at') { $pauseArray[ array_key_last($pauseArray) ]['ends_at'] = $pause->action_time; } }); $this->pauseTimes = $pauseArray; return $this; } public function timeTracking() { return [ 'starts_at' => $this->startsAt, 'ends_at' => $this->endsAt ]; } public function pauseTimes() { return $this->pauseTimes; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Policies/AbsencePolicy.php
app/Policies/AbsencePolicy.php
<?php namespace App\Policies; use App\Models\User; use App\Models\Absence; use App\Models\Location; use Illuminate\Auth\Access\HandlesAuthorization; class AbsencePolicy { use HandlesAuthorization; public function manageAbsence(User $user, Location $location) { return $user->hasLocationPermission($location, 'manageAbsence'); } public function addAbsence(User $user, $managingAbsenceForId, Location $location) { return $user->isLocationAdmin($location) || $user->id === (int)$managingAbsenceForId; } public function removeAbsence(User $user, Absence $absence, Location $location) { return $user->hasLocationPermission($location, 'manageAbsence') || $user->id === $absence->user_id; } public function approveAbsence(User $user, Location $location) { return $user->hasLocationPermission($location, 'approveAbsence'); } public function filterAbsences(User $user, Location $location) { return $user->hasLocationPermission($location, 'filterAbsences'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Policies/ReportPolicy.php
app/Policies/ReportPolicy.php
<?php namespace App\Policies; use App\Models\User; use App\Models\Location; use Illuminate\Auth\Access\HandlesAuthorization; class ReportPolicy { use HandlesAuthorization; /** * Determine whether the user can view any models. * * @param \App\Models\User $user * @return mixed */ public function switchEmployee(User $user, Location $location) { return ($user->belongsToLocation($location) && $user->hasLocationPermission($location, 'switchReportEmployee')) || $user->ownsLocation($location); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Policies/AccountPolicy.php
app/Policies/AccountPolicy.php
<?php namespace App\Policies; use App\Models\Account; use App\Models\User; use Illuminate\Auth\Access\HandlesAuthorization; class AccountPolicy { use HandlesAuthorization; /** * Determine whether the user can view any models. * * @param \App\Models\User $user * @return mixed */ public function viewAny(User $user) { // } /** * Determine whether the user can view the model. * * @param \App\Models\User $user * @param \App\Models\Account $account * @return mixed */ public function view(User $user, Account $account) { return $user->isAccountAdmin($account); } /** * Determine whether the user can create models. * * @param \App\Models\User $user * @return mixed */ public function create(User $user) { // } /** * Determine whether the user can update the model.@ * * @param \App\Models\User $user * @param \App\Models\Account $account * @return mixed */ public function update(User $user, Account $account) { return $user->isAccountAdmin($account); } /** * Determine whether the user can delete the model. * * @param \App\Models\User $user * @param \App\Models\Account $account * @return mixed */ public function delete(User $user, Account $account) { // } /** * Determine whether the user can restore the model. * * @param \App\Models\User $user * @param \App\Models\Account $account * @return mixed */ public function restore(User $user, Account $account) { // } /** * Determine whether the user can permanently delete the model. * * @param \App\Models\User $user * @param \App\Models\Account $account * @return mixed */ public function forceDelete(User $user, Account $account) { // } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Policies/TimeTrackingPolicy.php
app/Policies/TimeTrackingPolicy.php
<?php namespace App\Policies; use App\Models\User; use App\Models\Location; use App\Models\TimeTracking; use Illuminate\Auth\Access\HandlesAuthorization; class TimeTrackingPolicy { use HandlesAuthorization; public function updateTimeTracking(User $user, $managingTimeTrackingForId, Location $location) { return $user->hasLocationPermission($location, 'updateTimeTracking') || $user->id === (int)$managingTimeTrackingForId; } public function addTimeTracking(User $user, $managingTimeTrackingForId, Location $location) { return $user->isLocationAdmin($location) || $user->id === (int)$managingTimeTrackingForId; } public function assignProjects(User $user, Location $location) { return $user->hasLocationPermission($location, 'assignProjects') && $user->projects()->exists(); } public function filterTimeTracking(User $user, Location $location) { return $user->hasLocationPermission($location, 'filterTimeTracking'); } public function manageTimeTracking(User $user, Location $location) { return $user->hasLocationPermission($location, 'manageTimeTracking'); } public function removeTimeTracking(User $user, TimeTracking $timeTracking, Location $location) { return $user->hasLocationPermission($location, 'manageTimeTracking') || $user->id === $timeTracking->user_id; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Policies/UserPolicy.php
app/Policies/UserPolicy.php
<?php namespace App\Policies; use App\Models\User; use Illuminate\Auth\Access\HandlesAuthorization; class UserPolicy { use HandlesAuthorization; /** * Create a new policy instance. * * @return void */ public function update(User $user, User $employee) { return $user->ownsAccount($employee->account); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/Policies/LocationPolicy.php
app/Policies/LocationPolicy.php
<?php namespace App\Policies; use App\Models\User; use App\Models\Location; use Illuminate\Auth\Access\HandlesAuthorization; class LocationPolicy { use HandlesAuthorization; public function approveAbsence(User $user, Location $location) { return $user->hasLocationPermission($location, 'approveAbsence'); } public function removeAbsence(User $user, Location $location) { return $user->hasLocationPermission($location, 'removeAbsence'); } /** * Determine whether the user can add team members. * * @param \App\Models\User $user * @param \App\Models\Team $team * @return mixed */ public function addLocationMember(User $user, Location $location) { return $user->hasLocationPermission($location, 'addLocationMember'); } public function updateLocationMember(User $user, Location $location) { return $user->hasLocationPermission($location, 'updateLocationMember'); } /** * Determine whether the user can view the model. * * @param \App\Models\User $user * @param \App\Models\Account $account * @return mixed */ public function view(User $user, Location $location) { return $user->hasLocationPermission($location, 'editLocations'); } /** * Determine whether the user can update the model. * * @param \App\Models\User $user * @param \App\Models\Location $location * @return mixed */ public function update(User $user, Location $location) { return $user->hasLocationPermission($location, 'updateLocation'); } public function removeLocationMember(User $user, Location $location) { return $user->hasLocationPermission($location, 'removeLocationMember'); } public function addLocationAbsentType(User $user, Location $location) { return $user->hasLocationPermission($location, 'addLocationAbsentType'); } public function addDefaultRestingTime(User $user, Location $location) { return $user->hasLocationPermission($location, 'addDefaultRestingTime'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/View/Components/MultipleSelect.php
app/View/Components/MultipleSelect.php
<?php namespace App\View\Components; use Illuminate\View\Component; class MultipleSelect extends Component { public $options = []; public $selected = []; public $trackBy; public $label; /** * Create a new component instance. * * @return void */ public function __construct($options, $selected = [], $trackBy = 'id', $label = 'name') { $this->options = $options; $this->selected = $selected; $this->trackBy = $trackBy; $this->label = $label; } /** * Get the view / contents that represent the component. * * @return \Illuminate\Contracts\View\View|string */ public function render() { return view('components.multiple-select'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/View/Components/AppAccountLayout.php
app/View/Components/AppAccountLayout.php
<?php namespace App\View\Components; use Illuminate\View\Component; class AppAccountLayout extends Component { /** * Create a new component instance. * * @return void */ public function __construct() { // } /** * Get the view / contents that represent the component. * * @return \Illuminate\Contracts\View\View|string */ public function render() { return view('layouts.app-account'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/View/Components/GuestLayout.php
app/View/Components/GuestLayout.php
<?php namespace App\View\Components; use Illuminate\View\Component; class GuestLayout extends Component { /** * Get the view / contents that represents the component. * * @return \Illuminate\View\View */ public function render() { return view('layouts.guest'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/View/Components/AppProfileLayout.php
app/View/Components/AppProfileLayout.php
<?php namespace App\View\Components; use Illuminate\View\Component; class AppProfileLayout extends Component { /** * Create a new component instance. * * @return void */ public function __construct() { // } /** * Get the view / contents that represent the component. * * @return \Illuminate\Contracts\View\View|string */ public function render() { return view('layouts.app-profile'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/app/View/Components/AppLayout.php
app/View/Components/AppLayout.php
<?php namespace App\View\Components; use Illuminate\View\Component; class AppLayout extends Component { /** * Get the view / contents that represents the component. * * @return \Illuminate\View\View */ public function render() { return view('layouts.app'); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/bootstrap/app.php
bootstrap/app.php
<?php /* |-------------------------------------------------------------------------- | Create The Application |-------------------------------------------------------------------------- | | The first thing we will do is create a new Laravel application instance | which serves as the "glue" for all the components of Laravel, and is | the IoC container for the system binding all of the various parts. | */ $app = new Illuminate\Foundation\Application( $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__) ); /* |-------------------------------------------------------------------------- | Bind Important Interfaces |-------------------------------------------------------------------------- | | Next, we need to bind some important interfaces into the container so | we will be able to resolve them when needed. The kernels serve the | incoming requests to this application from both the web and CLI. | */ $app->singleton( Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class ); $app->singleton( Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class ); $app->singleton( Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class ); /* |-------------------------------------------------------------------------- | Return The Application |-------------------------------------------------------------------------- | | This script returns the application instance. The instance is given to | the calling script so we can separate the building of the instances | from the actual running of the application and sending responses. | */ return $app;
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/tests/TestCase.php
tests/TestCase.php
<?php namespace Tests; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { use CreatesApplication; use RefreshDatabase; }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/tests/CreatesApplication.php
tests/CreatesApplication.php
<?php namespace Tests; use Illuminate\Contracts\Console\Kernel; trait CreatesApplication { /** * Creates the application. * * @return \Illuminate\Foundation\Application */ public function createApplication() { $app = require __DIR__.'/../bootstrap/app.php'; $app->make(Kernel::class)->bootstrap(); return $app; } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/tests/Feature/DeleteApiTokenTest.php
tests/Feature/DeleteApiTokenTest.php
<?php namespace Tests\Feature; use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Str; use Laravel\Jetstream\Features; use Laravel\Jetstream\Http\Livewire\ApiTokenManager; use Livewire\Livewire; use Tests\TestCase; class DeleteApiTokenTest extends TestCase { use RefreshDatabase; public function test_api_tokens_can_be_deleted() { if (! Features::hasApiFeatures()) { return $this->markTestSkipped('API support is not enabled.'); } $this->actingAs($user = User::factory()->withPersonalTeam()->create()); $token = $user->tokens()->create([ 'name' => 'Test Token', 'token' => Str::random(40), 'abilities' => ['create', 'read'], ]); Livewire::test(ApiTokenManager::class) ->set(['apiTokenIdBeingDeleted' => $token->id]) ->call('deleteApiToken'); $this->assertCount(0, $user->fresh()->tokens); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false
eporsche/daybreak
https://github.com/eporsche/daybreak/blob/622d67f67470933977f13a44b19849ddb1cc0d8c/tests/Feature/UpdateLocationNameTest.php
tests/Feature/UpdateLocationNameTest.php
<?php namespace Tests\Feature; use Tests\TestCase; use App\Models\User; use Livewire\Livewire; use App\Models\Location; use Illuminate\Foundation\Testing\RefreshDatabase; use App\Http\Livewire\Locations\UpdateLocationNameForm; class UpdateLocationNameTest extends TestCase { use RefreshDatabase; public function test_location_names_can_be_updated() { $user = User::factory() ->withOwnedAccount() ->create(); $location = $user->ownedLocations() ->save($location = Location::factory()->make()); $location->users()->attach( $otherUser = User::factory()->create(), ['role' => 'admin'] ); $this->actingAs($user); Livewire::test(UpdateLocationNameForm::class, ['location' => $location->fresh()]) ->set(['state' => ['name' => 'Test Location']]) ->call('updateLocationName'); $this->assertEquals('Test Location', $location->fresh()->name); } }
php
MIT
622d67f67470933977f13a44b19849ddb1cc0d8c
2026-01-05T05:21:01.959950Z
false