получилось вот так, как думаете это правильно, или есть гораздо лаконичные решения?
Код: Выделить всё
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->user_id !== Yii::$app->user->id){
throw new HttpException('404', 'Acess denied');
} else {
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
}
public function actionDelete($id)
{
$model = $this->findModel($id);
if ($model->user_id !== Yii::$app->user->id){
throw new HttpException('404', 'Acess denied');
} else {
$model->delete();
return $this->redirect(['index']);
}
}