public function markAllRead() { foreach (ForumMail::where('to_id', Auth::user()->id)->whereNull('received_at')->get() as $mail) { $mail->received_at = new DateTime(); $mail->save(); } return Redirect::to('/dashboard/mail'); }
$(".mail-user-checker").html("<i class='icon-user'></i> Waiting to verify username..."); if(tinyMCE.get("mail-message")) tinyMCE.get("mail-message").setContent(""); $('#message-modal').show(); } self.reply = function() { self.messageRecipient(self.activeMail().from); self.messageSubject("RE: " + self.activeMail().title); tinyMCE.get("mail-message").setContent("<blockquote>" + self.activeMail().body + "</blockquote><p></p>"); $('#message-modal').show(); } <?php $user = Auth::user(); $inbox_results = $user->mail()->orderBy('created_at', 'desc')->get(); $outbox_results = ForumMail::where('from_id', $user->id)->orderBy('created_at', 'desc')->get(); ?> @foreach($inbox_results as $mail) self.mailList.push({ id: {{$mail->id}}, title: "{{{$mail->title}}}", from: "{{$mail->from()}}", to: "{{$mail->to->username}}", time: "{{$mail->created_at->diffForHumans()}}", time_full: "{{$mail->created_at->format('l, F jS Y \a\t g:i A')}}", from_id: "{{$mail->from_id}}", read: ko.observable({{$mail->read() == 1 ? 'true' : 'false'}}), body: {{json_encode(nl2br($mail->body))}} }); @endforeach