Ejemplo n.º 1
0
 /**
  * Display all of the e-mail addresses.
  *
  * @return Response
  */
 public function emails()
 {
     // Update e-mail dates
     Guest::where('email', '<>', '')->whereNull('email_date')->update(['email_date' => Carbon::now()]);
     // List non-blank e-mail dates
     $guests = Guest::whereNotNull('email_date')->orderBy('email_date', 'desc')->get();
     // Generate a 2d list
     $mail_list = $guests->reduce(function ($acc, $item) {
         $acc[$item->email_date->format('l, F jS, Y')][] = $item->full_name . ' &lt;' . $item->email . '&gt;;';
         return $acc;
     }, []);
     return view('classmates.emails', compact('mail_list'));
 }