/** * Creates a new Node model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Node(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => (string) $model->_id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionAdd() { $model = new Node(); if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('add', ['model' => $model]); } }
public function add(RequestSave $request, $id = null) { if (is_null($id)) { if (Request::isMethod('post')) { $node = new Node(); $node->name = $request->name; $node->ip = $request->ip; $node->save(); } } return view('scripts.simulator.add'); }
public function add($request, $response, $args) { $node = new Node(); $node->name = $request->getParam('name'); $node->server = $request->getParam('server'); $node->method = $request->getParam('method'); $node->custom_method = $request->getParam('custom_method'); $node->info = $request->getParam('info'); $node->type = $request->getParam('type'); $node->status = $request->getParam('status'); $node->sort = $request->getParam('sort'); if (!$node->save()) { $rs['ret'] = 0; $rs['msg'] = "添加失败"; return $response->getBody()->write(json_encode($rs)); } $rs['ret'] = 1; $rs['msg'] = "节点添加成功"; return $response->getBody()->write(json_encode($rs)); }
/** * Create a new child node * * @param Request $request * @param $id * @return \Illuminate\Http\JsonResponse */ public function addChild(Request $request, $id) { $parent = $this->findModelById($id); $name = $request->get('name'); $child = new Node(['name' => $name]); $child->save(); $child->makeChildOf($parent); return Response::json('success'); }