feat: automatically end absences that expired

This commit is contained in:
2022-04-03 20:35:55 +01:00
parent 06df0e7906
commit a9c2617713
3 changed files with 55 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Services;
use App\Absence;
use App\Exceptions\AbsenceNotActionableException;
use App\User;
use Carbon\Carbon;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
@@ -148,6 +149,15 @@ class AbsenceService
}
public function endExpired()
{
foreach (Absence::all() as $absence)
{
if (!Carbon::parse($absence->predicted_end)->isFuture()) {
$absence->setEnded();
}
}
}