bug fixes, daily reports, holidays
This commit is contained in:
@@ -29,4 +29,21 @@ class OfficeLocation extends Model
|
||||
{
|
||||
return $this->hasMany(OfficeLocationDocument::class, 'office_location_id');
|
||||
}
|
||||
public function holidays()
|
||||
{
|
||||
return $this->hasMany(PublicHoliday::class)->orderBy('holiday_date');
|
||||
}
|
||||
public function isHoliday($date)
|
||||
{
|
||||
$parsedDate = \Carbon\Carbon::parse($date);
|
||||
|
||||
return $this->holidays()->where(function($query) use ($parsedDate) {
|
||||
$query->whereDate('holiday_date', $parsedDate->format('Y-m-d'))
|
||||
->orWhere(function($q) use ($parsedDate) {
|
||||
$q->where('is_recurring', true)
|
||||
->whereMonth('holiday_date', $parsedDate->month)
|
||||
->whereDay('holiday_date', $parsedDate->day);
|
||||
});
|
||||
})->exists();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user