Ejemplo n.º 1
0
 /**
  * postSave
  *
  * @param Data $data
  *
  * @return  void
  */
 protected function postSave(Data $data)
 {
     $this->post = $data;
     $this->topic = $topic = $this->model->getRecord('Topic');
     $topic->load($data->topic_id);
     $this->category = $this->model->getRecord('Category');
     $this->category->load($topic->category_id);
     if ($this->isNew) {
         if (!$data->primary) {
             $user = User::get();
             $date = DateTime::create();
             $topic->last_reply_user = $user->id;
             $topic->last_reply_post = $data->id;
             $topic->last_reply_date = $date->toSql();
             $topic->replies++;
             $topic->store();
         } else {
             $this->category->topics++;
         }
         $this->category->posts++;
         $this->category->store();
     }
     // Mail
     $this->sendMail($topic, $data);
     // Add Notification
     Notification::addNotification('topic', $topic->id, $topic->user_id);
 }