public function mark_as_read() { $this->updateAttribute('has_seen', true); if (!Dmail::where("to_id = ? AND has_seen = false", current_user()->id)->exists()) { current_user()->updateAttribute('has_mail', false); } }
public function markAllRead() { if ($this->params()->commit == "Yes") { foreach (Dmail::where("to_id = ? and has_seen = false", $this->current_user->id)->take() as $dmail) { $dmail->updateAttribute('has_seen', true); } $this->current_user->updateAttribute('has_mail', false); $this->respond_to_success("All messages marked as read", ['action' => "inbox"]); } else { $this->redirectTo("#inbox"); } }