/** * Execute the job. * * @return bool */ public function handle() { $this->service->name = $this->request->input('name'); $this->service->description = $this->request->input('description'); if ($this->service->save()) { $this->dispatch(new CreateFirst($this->service)); return true; } return false; }
/** * Creates a new Service model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Service(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public static function createBranchService($branch_id, $business_name) { $service = new Service(); $service->name = $business_name . " Service"; $service->status = 1; $service->branch_id = $branch_id; $service->save(); return $service->service_id; }
public function postCreate() { $validator = Validator::make(Input::all(), Service::$rules); if ($validator->passes()) { $service = new Service(); $service->title = Input::get('title'); $service->slug = Input::get('slug'); $service->short_description = Input::get('short_description'); $service->long_description = Input::get('long_description'); $service->on_the_home = (int) Input::get('on_the_home'); $service->save(); flash()->success('Элемент добавлен'); return Redirect::to("/admin/services/edit/{$service->id}"); } flash()->error('Ошибка'); return Redirect::back(); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Service $service, Request $request) { //$id = $request->route('products'); //dd($id); $validationRules = ['short_name' => 'required|alpha_spaces_numbers_etc|max:255|unique:services', 'unit' => 'required|alpha_spaces_numbers_etc|max:50', 'period' => 'required|alpha_spaces_numbers_etc|max:100', 'documents' => 'required|alpha_spaces_numbers_etc', 'price' => 'required|numeric']; $v = Validator::make($request->all(), $validationRules); if ($v->fails()) { return redirect()->back()->withErrors($v->errors())->withInput(); } $service->short_name = $request->short_name; $service->full_name = $request->full_name; $service->unit = $request->unit; $service->period = $request->period; $service->documents = $request->documents; $service->price = $request->price; if ($request->need_station) { $service->need_station = 1; } $service->save(); return redirect('services')->with('alert-success', 'Услуга успешно добавлена!'); }
public function import($services, $deviceIndex) { $subscriptionCount = 0; foreach ($services as $service) { if (isset($service['serviceUuid']) && is_array($service['serviceUuid'])) { $service['serviceUuid'] = $service['serviceUuid'][0]; } if (!($serviceModel = Service::find()->where(array('device' => $deviceIndex, 'serviceUuid' => $service['serviceUuid']))->one())) { $serviceModel = new Service(); } $service = array_merge($service, array('device' => $deviceIndex)); $serviceModel->setAttributes($service); if ($serviceModel->save()) { $serviceIndex = $serviceModel->getPrimaryKey(); if (isset($service['charasteristics'])) { $subscriptionCount += \app\models\Charasteristic::import($service['charasteristics'], $serviceIndex); } } //else { //die(print_r( $serviceModel->getErrors(),true)); //} } return $subscriptionCount; }
/** * Update the specified resource in storage. * * @param Business $business Business to update service of * @param Service $service Service to update * * @return Response */ public function update(Business $business, Service $service, Request $request) { logger()->info(__METHOD__); logger()->info(sprintf('businessId:%s serviceId:%s', $business->id, $service->id)); $this->authorize('manageServices', $business); // BEGIN ////////////////// // FOR REFACTOR // ////////////////// $service->update(['name' => $request->get('name'), 'color' => $request->get('color'), 'duration' => $request->get('duration'), 'description' => $request->get('description'), 'prerequisites' => $request->get('prerequisites')]); if ($request->get('type_id')) { $service->type()->associate($request->get('type_id')); $service->save(); } flash()->success(trans('manager.business.service.msg.update.success')); return redirect()->route('manager.business.service.show', [$business, $service]); }
/** * Execute the job. * * @return bool */ public function handle() { $this->service->name = $this->request->input('name', $this->service->name); $this->service->description = $this->request->input('description', $this->service->description); return $this->service->save(); }
/** * Store service into database * * @param array $input * @return boolean */ public function createService($input) { $result = Service::validate($input); if (!is_bool($result)) { return $this->setMessage($result); } $service = new Service(); $service->service_name = $input['name']; $service->description = $input['description']; $service->save(); return $result; }
/** *新增和修改提交 * @return array */ public function actionSubmit() { $params = Yii::$app->request->post(); $model = new Service(); $params["create_at"] = date("Y-m-d"); $params["user_id"] = Yii::$app->user->getId(); $params["status"] = 0; $data = array(); //yii自动生成的form参数是Enterprise["name"]这种形式,获取后就会是在一个Enterprise中 $data["Service"] = $params; \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; if ($model->load($data) && $model->save()) { return ["success" => true]; } else { return ["success" => false, "error_code" => 1]; } }