public function schedule(User $user, FormDefinition $form) { try { if ($form->group()->first()->isCreator($user->id) || $form->group()->first()->isAdmin($user->id)) { return true; } else { return false; } } catch (\Exception $e) { return false; } }
public static function notify() { $forms = FormDefinition::where('status', 'Reviewing'); }
public static function scheduleForms() { $forms = FormDefinition::where('status', '!=', 'archived')->get(); $time = Carbon::now('America/Detroit'); foreach ($forms as $form) { echo "<hr>"; echo "TIME NOW: {$time} <br>"; echo "Form Start: " . $form->submissions_start . "<br>"; echo "Form Stop: " . $form->submissions_end . "<br>"; echo "Scores Due: " . $form->scores_due . "<br>"; if ($form->status == 'Drafting') { continue; } if ($form->submissions_start < $time) { echo "Form needs to open!<br>"; $form->status = "Accepting"; } if ($form->submissions_end < $time) { echo "Form needs to close!<br>"; $form->status = "Reviewing"; } if ($form->scores_due < $time) { echo "Form needs to complete<br>"; $form->status = "Scored"; } echo "<br>"; echo $form->name . " status is now: " . $form->status; echo "<br>"; echo "<br>"; echo "<hr>"; $form->save(); } }