From d2227d8e3efca1b0763debe5ef2b97463fcf9b18 Mon Sep 17 00:00:00 2001 From: JoshuaMicallefYBSU <91457812+JoshuaMicallefYBSU@users.noreply.github.com> Date: Mon, 19 Aug 2024 05:25:38 +1000 Subject: [PATCH] PleaseWork --- app/Console/Kernel.php | 2 +- app/Jobs/DiscordTrainingUpdates.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 2c991319..0e2ba958 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -106,7 +106,7 @@ protected function schedule(Schedule $schedule) $schedule->job(new ProcessSessionReminders())->daily(); // Check Training Threads Status (Once per week) - $schedule->job(new DiscordTrainingUpdates())->weeklyOn(7, '19:10'); + $schedule->job(new DiscordTrainingUpdates())->weeklyOn(7, '19:28'); // Discord role updating //$schedule->job(new UpdateDiscordUserRoles)->twiceDaily(6, 18); diff --git a/app/Jobs/DiscordTrainingUpdates.php b/app/Jobs/DiscordTrainingUpdates.php index d4e4d467..01482afd 100644 --- a/app/Jobs/DiscordTrainingUpdates.php +++ b/app/Jobs/DiscordTrainingUpdates.php @@ -58,7 +58,7 @@ public function handle() } // See if CID is still a student - $student = Student::where('current', 1)->where('user_id', $cid)->firstOrFail(); + $student = Student::where('current', 1)->where('user_id', $cid)->first(); if($student !== null){ @@ -102,11 +102,11 @@ public function handle() // See if user is still a student if($cid !== null){ - $student = Student::where('current', 1)->where('user_id', $cid)->firstOrFail(); - - // Check Lable is 'In Progress' or 'Ready For Pick-Up' - if($student->hasLabel('In Progress') || $student->hasLabel('Ready For Pick-Up')){ - + $student = Student::whereCurrent(true)->where('user_id', $cid)->firstOrFail(); + + //Is student already ready for assessment? + if ($student && ($student->hasLabel('In Progress') !== false || $student->hasLabel('Ready For Pick-Up') !== false)) { + // Check Sessions Upcoming $upcoming_sessions = TrainingSession::where('student_id', $student->id)->whereBetween('scheduled_time', [Carbon::now(), Carbon::now()->addDays(7)])->first();