Merge branch '#22-vacation-calendar' into #41-email-notifications

This commit is contained in:
EwelinaLasowy
2022-02-15 10:07:08 +01:00
19 changed files with 392 additions and 213 deletions

View File

@@ -14,6 +14,7 @@ use Illuminate\Support\Carbon;
* @property Carbon $date
* @property User $user
* @property VacationRequest $vacationRequest
* @property YearPeriod $yearPeriod
*/
class Vacation extends Model
{
@@ -34,4 +35,9 @@ class Vacation extends Model
{
return $this->belongsTo(VacationRequest::class);
}
public function yearPeriod(): BelongsTo
{
return $this->belongsTo(YearPeriod::class);
}
}

View File

@@ -21,7 +21,6 @@ use Toby\Domain\Enums\VacationType;
* @property VacationRequestState $state
* @property Carbon $from
* @property Carbon $to
* @property int $estimated_days
* @property string $comment
* @property User $user
* @property YearPeriod $yearPeriod
@@ -75,6 +74,11 @@ class VacationRequest extends Model
return $query->whereIn("state", $states);
}
public function scopeNoStates(Builder $query, array $states): Builder
{
return $query->whereNotIn("state", $states);
}
public function scopeOverlapsWith(Builder $query, self $vacationRequest): Builder
{
return $query->where("from", "<=", $vacationRequest->to)