From 22edca1f988b8e16f612a7f636e4431b964c089b Mon Sep 17 00:00:00 2001 From: JoshuaMicallefYBSU <91457812+JoshuaMicallefYBSU@users.noreply.github.com> Date: Fri, 16 Aug 2024 20:36:19 +1000 Subject: [PATCH] Add Controller to HomePage --- .../Controllers/Training/InstructingController.php | 13 +++++++++++-- app/Models/News/HomeNewControllerCert.php | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Training/InstructingController.php b/app/Http/Controllers/Training/InstructingController.php index 19be9281..7fe754b4 100644 --- a/app/Http/Controllers/Training/InstructingController.php +++ b/app/Http/Controllers/Training/InstructingController.php @@ -4,6 +4,7 @@ use App\Http\Controllers\Controller; use App\Models\Roster\RosterMember; +use App\Models\News\HomeNewControllerCert; use App\Models\Training\Instructing\Instructors\Instructor; use App\Models\Training\Instructing\Links\InstructorStudentAssignment; use App\Models\Training\Instructing\Links\StudentStatusLabelLink; @@ -479,8 +480,16 @@ public function certifyStudent($cid) $link->save(); // Unassign Instructor from Student - $instructor_id = InstructorStudentAssignment::where('student_id', $student->id)->firstOrFail(); - $instructor_id->delete(); + $instructor_link = InstructorStudentAssignment::where('student_id', $cid); + $instructor_link->delete(); + + // Create new certification (for home page) + $controller_cert = new HomeNewControllerCert([ + 'controller_id' => $cid, + 'user_id' => $cid, + 'timestamp' => Carbon::now(), + ]); + $controller_cert->save(); // Update Thread Tag to match site $discord = new DiscordClient(); diff --git a/app/Models/News/HomeNewControllerCert.php b/app/Models/News/HomeNewControllerCert.php index 2dcab173..f85814ce 100644 --- a/app/Models/News/HomeNewControllerCert.php +++ b/app/Models/News/HomeNewControllerCert.php @@ -28,6 +28,10 @@ */ class HomeNewControllerCert extends Model { + protected $fillable = [ + 'controller_id', 'user_id', 'timestamp', + ]; + public function controller() { return $this->belongsTo(User::class, 'controller_id');