request->post('tmcType'); $tmcType = TmcType::findOne($tmcTypeId); $inventoryNum = Yii::$app->request->post('inventoryNum'); $ip = Yii::$app->request->post('ip'); $mac = Yii::$app->request->post('mac'); if ($ip && !filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { die('Неверный IP'); } $tmc = new Tmc(); $tmc->title = $tmcType->title . ' ' . $inventoryNum; $tmc->tmc_type = $tmcTypeId; $tmc->inventory_num = $inventoryNum; $tmc->ip = $ip; $tmc->mac = $mac; $tmc->storage = (int) Yii::$app->request->post('storage'); $tmc->desc = Yii::$app->request->post('desc'); $tmc->status = TmcStatus::TMC_STATUS_IN_STORAGE; $tmc->company = (int) Yii::$app->request->post('company'); $tmc->receipt_date = (new DateTime())->format('Y-m-d H:i:s'); $tmc->save(); $storage = Storage::findOne($tmc->storage); $storage->tmc = $tmc->id; $storage->save(); Yii::$app->response->redirect('/index.php?act=tmc/detail/added&id=' . $tmc->id)->send();