@@ -89,17 +89,17 @@ public function handlePeriodicEventStart(): void
8989 public function handlePeriodicEventReminder (int $ daysBeforeEnd ): void
9090 {
9191 if ($ daysBeforeEnd < 3 ) {
92- $ userCount = $ this ->usersHaventFilledOutTheForm ( )->count ();
92+ $ userCount = SemesterEvaluationController:: usersHaventFilledOutTheForm ( $ this ->semester () )->count ();
9393 Mail::to (config ('contacts.mail_membra ' ))->queue (new EvaluationFormReminder ($ userCount , $ this ->getDeadline ()));
9494 }
9595 }
9696
9797 /**
9898 * Send email about results and deactivate collegists who did not fill out the form.
9999 */
100- public function handlePeriodicEventEnd ( )
100+ public static function finalize ( $ semester )
101101 {
102- $ users = $ this -> usersHaventFilledOutTheForm ();
102+ $ users = SemesterEvaluationController:: usersHaventFilledOutTheForm ($ semester );
103103 $ users_names = $ users ->pluck ('name ' )->toArray ();
104104
105105 if (User::secretary ()) {
@@ -137,7 +137,6 @@ public function show()
137137 $ this ->authorize ('fillOrManage ' , SemesterEvaluation::class);
138138
139139 return view ('secretariat.evaluation-form.app ' , [
140- 'phd ' => user ()->educationalInformation ->isSenior (),
141140 'user ' => user (),
142141 'faculties ' => Faculty::all (),
143142 'workshops ' => Workshop::all (),
@@ -146,7 +145,7 @@ public function show()
146145 'community_services ' => user ()->communityServiceRequests ()->where ('semester_id ' , Semester::current ()->id )->get (),
147146 'position_roles ' => user ()->roles ()->whereIn ('name ' , Role::STUDENT_POSTION_ROLES )->get (),
148147 'periodicEvent ' => $ this ->periodicEvent (),
149- 'users_havent_filled_out ' => user ()->can ('manage ' , SemesterEvaluation::class) ? $ this ->usersHaventFilledOutTheForm ( ) : null ,
148+ 'users_havent_filled_out ' => user ()->can ('manage ' , SemesterEvaluation::class) ? SemesterEvaluationController:: usersHaventFilledOutTheForm ( $ this ->semester () ) : null ,
150149 ]);
151150 }
152151
@@ -243,11 +242,17 @@ public function store(Request $request)
243242 /**
244243 * @return User[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection
245244 */
246- public function usersHaventFilledOutTheForm ()
245+ public static function usersHaventFilledOutTheForm ($ semester )
247246 {
248- return User::withRole (Role::COLLEGIST )->verified ()->whereDoesntHave ('semesterStatuses ' , function ($ query ) {
249- $ query ->where ('semester_id ' , $ this ->semester ()?->succ()?->id);
250- })->get ();
247+ return User::withRole (Role::COLLEGIST )
248+ ->whereDoesntHave ('roles ' , function ($ query ) {
249+ $ query ->where ('name ' , Role::SENIOR );
250+ })
251+ ->verified ()
252+ ->whereDoesntHave ('semesterStatuses ' , function ($ query ) use ($ semester ) {
253+ $ query ->where ('semester_id ' , $ semester ?->succ()?->id);
254+ })
255+ ->get ();
251256 }
252257
253258 /**
0 commit comments