Fix error preventing users from deleting their own entires due to timezone issues.
This commit is contained in:
Matt Young 2024-12-20 12:50:10 -06:00
parent 055ffad98e
commit e7acaa2448
1 changed files with 11 additions and 2 deletions

View File

@ -4,6 +4,7 @@ namespace App\Policies;
use App\Models\Entry;
use App\Models\User;
use Carbon\Carbon;
use function is_null;
@ -61,11 +62,19 @@ class EntryPolicy
if ($user->is_admin) {
return true;
}
// Return false if $entry->audition->entry_deadline is in the past, continue if not
if ($entry->audition->entry_deadline < now()) {
// Check entry deadline
$currentDate = Carbon::now('America/Chicago');
$currentDate = $currentDate->format('Y-m-d');
if ($entry->audition->entry_deadline < $currentDate) {
return false;
}
// OLD VERSION Return false if $entry->audition->entry_deadline is in the past, continue if not
// if ($entry->audition->entry_deadline < now()) {
// return false;
// }
return $user->school_id == $entry->student->school_id;
}