diff --git a/app/Http/Controllers/Training/InstructingController.php b/app/Http/Controllers/Training/InstructingController.php index 237b2578..256f7353 100644 --- a/app/Http/Controllers/Training/InstructingController.php +++ b/app/Http/Controllers/Training/InstructingController.php @@ -457,6 +457,10 @@ public function certifyStudent($cid) { $student = Student::where('user_id', $cid)->firstOrFail(); + //Make as not current + $student->current = false; + $student->save(); + // Remove Student Status & Set Controller as Active $student->user->removeRole('Student'); $student->user->assignRole('Certified Controller'); @@ -472,13 +476,17 @@ public function certifyStudent($cid) ]); $link->save(); + // Unassign Instructor from Student + $instructor_id = InstructorStudentAssignment::where('student_id', $student->id)->firstOrFail(); + $instructor_id->delete(); + // Update Thread Tag to match site $discord = new DiscordClient(); $discord->EditThreadTag('Completed', $student->user->fullName('FLC')); // Close Training Thread Out & Send Completion Message $discord = new DiscordClient(); - $discord->closeTrainingThread($student->user->fullName('FLC'), 'certfied'); + $discord->closeTrainingThread($student->user->fullName('FLC'), 'certify'); // Update Roster with Certification Status $rosterMember = RosterMember::where('cid', $cid)->firstOrFail(); @@ -486,7 +494,7 @@ public function certifyStudent($cid) //Assign values $rosterMember->certification = 'Certified'; $rosterMember->active = 1; - $rosterMember->remarks = 'Certified on NAT_FSS (Automatic Message)'; + $rosterMember->remarks = 'Certified on NAT_FSS (Web Message)'; $rosterMember->date_certified = Carbon::now(); //User @@ -512,6 +520,8 @@ public function certifyStudent($cid) $discord->assignRole($rosterMember->user->discord_user_id, $roles['student']); $discord->removeRole($rosterMember->user->discord_user_id, $roles['certified']); } + + } else { Session::flash('info', 'Unable to add Discord permissions automatically.'); } diff --git a/app/Models/Users/User.php b/app/Models/Users/User.php index 0497a6d3..8659a05f 100644 --- a/app/Models/Users/User.php +++ b/app/Models/Users/User.php @@ -155,6 +155,18 @@ public function isBot() return false; } + // // Assign role to user Model + // public function assignRole($role) + // { + // return $role; + // } + + // // Remove role from user Model + // public function removeRole($role) + // { + + // } + /** * Return articles that the user has written. * @@ -245,6 +257,8 @@ public function highestRole() return $this->roles[0]; } + + /** * Get the user's name in requested format. * FLC - First, Last, CID