コード例 #1
0
 /**
  * Recalculates the scores for the competition entries and (optionally) sends
  * a notification email to the contestants.
  */
 public function score()
 {
     $msg = "Updated the scores for the competition entries";
     $entries = Entry::confirmed()->get();
     foreach ($entries as $entry) {
         $entry->calculateScore();
     }
     if (Input::has('send_notifications')) {
         $send_notifications = Input::get('send_notifications');
         if ($send_notifications) {
             $entries->sortByDesc('score');
             $top_three = $entries->take(3);
             $contestants = $entries->lists('email');
             Mail::send('emails.score', array('entries' => $top_three), function ($message) use($contestants) {
                 $message->to($contestants)->subject('RWC 2015 Competition');
             });
             $msg = "Updated the scores for the competition entries and sent emails to the contestants.";
         }
     }
     return Redirect::route('admin.index')->withInfo($msg);
 }
コード例 #2
0
 public function index()
 {
     $entries = Entry::confirmed()->orderBy('score', 'desc')->orderBy('first_name')->orderBy('last_name')->get();
     return View::make('home')->with('entries', $entries);
 }