示例#1
0
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     parent::prepareExecute();
     $this->record->load($this->data['id']);
     $this->category = $this->model->getRecord('Category');
     $this->category->load($this->record->category_id);
 }
示例#2
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);
 }
示例#3
0
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     parent::prepareExecute();
     $this->useTransaction(true);
     if (isset($this->data['id'])) {
         $this->record->load($this->data['id']);
     }
     $this->catid = $this->input->get('category');
     $this->category = new CategoryRecord();
     $this->category->load($this->catid);
     $this->data['category_id'] = $this->catid;
 }
示例#4
0
 /**
  * Method to test rebuildPath().
  *
  * @return void
  *
  * @covers Windwalker\Record\NestedRecord::rebuildPath
  */
 public function testRebuildPath()
 {
     $this->instance->load(4)->rebuildPath();
     $this->assertEquals('flower/olive', $this->instance->path);
 }