コード例 #1
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $last_executor_id = $model->executor_id;
     $modelHistory = new TaskHistory();
     if ($model->load(Yii::$app->request->post(), '') && $model->save()) {
         if ($last_executor_id != $model->executor_id && $modelHistory->load(Yii::$app->request->post(), '')) {
             $modelHistory->task_id = $model->id;
             $modelHistory->last_executor_id = $last_executor_id;
             $modelHistory->new_executor_id = $model->executor_id;
             $modelHistory->save();
         }
         return $model;
     }
     throw new ServerErrorHttpException('Failed to update the object for unknown reason.');
 }
コード例 #2
0
ファイル: Task.php プロジェクト: defektrain/sgm-rest
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTaskHistories()
 {
     return $this->hasMany(TaskHistory::className(), ['task_id' => 'id']);
 }