public function actionTrack() { $model = Track::findOne(Yii::$app->request->post('pk', '')); $ownerId = $model->release->artist->user_id; return self::update($model, $ownerId); }
/** * Finds the Track model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Track the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Track::findOne($id)) !== null) { if ($model->release->artist->user_id != Yii::$app->user->id) { throw new ForbiddenHttpException(); } return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }