$notification->saveByIdUser(7);
public function actionView($id)
{
$model = $this->findModel($id);
$notification = new Notification();
$shipping = $model->idShipping;
// $this->view->params['notification'] = $notification;
$shipping = new Courier();
if ($shipping->load(Yii::$app->request->post()) && $shipping->save()) {
$model->id_shipping = $shipping->id;//Оформление доставки
$notification->id_user = 7;//оформление уведомление доставки
$notification->name = 'Доставка '.$model->description;
$notification->saveNotification;
$model->save();
return $this->redirect(['view', 'id' => $model->id_zakaz]);
}
if ($model->load(Yii::$app->request->post())) {
$model->file = UploadedFile::getInstance($model, 'file');//Выполнена работа дизайнером
if(isset($model->file))
{
$model->file->saveAs('maket/Maket_'.$model->id_zakaz.'.'.$model->file->extension);
$model->maket = 'Maket_'.$model->id_zakaz.'.'.$model->file->extension;
$model->status = 4;
$notification->id_user = 5;//оформление уведомление выполение работы дизайнера
$notification->name = 'Дизайнер выполнил работу №'.$model->id_zakaz.' '.$model->description;
$notification->saveNotification;
}
$model->save();
if ($model->status == 3) {
$notification->id_user = 3;//оформление уведомление дизайнеру
$notification->name = 'Новый заказ №'.$model->id_zakaz;
$notification->saveNotification;
} elseif ($model->status == 6) {
$notification->id_user = 6;//оформление уведомление мастеру
$notification->name = 'Новый заказ №'.$model->id_zakaz;
$notification->saveNotification;
}
return $this->redirect(['view', 'id' => $model->id_zakaz]);
}
return $this->render('view', [
'model' => $this->findModel($id),
'notification' => $notification,
'user_name' => $user_name,
'shipping' => $shipping,
'file' => $file,
]);
}
use app\models\Notification;
class ZakazController extends Controller
{
public function actionView($id)
{
$model = $this->findModel($id);
$notification = new Notification();
$shipping = $model->idShipping;
$statusDisain = $model->statusDisain;
$status = $model->status;
$shipping = new Courier();
if ($shipping->load(Yii::$app->request->post()) && $shipping->save()) {
$model->id_shipping = $shipping->id;//Оформление доставки
$notification->id_user = 7;//оформление уведомление
$notification->name = 'Доставка '.$model->description;
$notification->active = 0;
$notification->save();
$model->save();
return $this->redirect(['view', 'id' => $model->id_zakaz]);
}
if ($model->load(Yii::$app->request->post())) {
$model->file = UploadedFile::getInstance($model, 'file');//Выполнена работа дизайнером
if(isset($model->file))
{
$model->file->saveAs('maket/Maket_'.$model->id_zakaz.'.'.$model->file->extension);
$model->maket = 'Maket_'.$model->id_zakaz.'.'.$model->file->extension;
$model->status = 4;
$notification->id_user = 5;//оформление уведомление
$notification->name = 'Дизайнер выполнил работу №'.$model->id_zakaz.' '.$model->description;
$notification->active = 0;
}
$model->save();
if ($model->status == 3) {
$notification->id_user = 3;//оформление уведомление дизайнеру
$notification->name = 'Новый заказ №'.$model->id_zakaz;
$notification->active = 0;
$notification->save();
} elseif ($model->status == 6) {
$notification->id_user = 6;//оформление уведомление мастеру
$notification->name = 'Новый заказ №'.$model->id_zakaz;
$notification->active = 0;
$notification->save();
}
return $this->redirect(['view', 'id' => $model->id_zakaz]);
}
return $this->render('view', [
'model' => $this->findModel($id),
'notification' => $notification,
'user_name' => $user_name,
'shipping' => $shipping,
'file' => $file,
]);
}
}
То есть выходит на эту строку $notification->id_user = $id;