当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::save方法代码示例

本文整理汇总了PHP中app\models\Client::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::save方法的具体用法?PHP Client::save怎么用?PHP Client::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Client的用法示例。


在下文中一共展示了Client::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 /**
  * create new client
  * @return avoid
  */
 public function actionCreate()
 {
     $client = new Client();
     $groups = new Group();
     $groups_clients = new GroupClient();
     if ($client->load(Yii::$app->request->post()) && $client->validate()) {
         // get post variable of GroupClient
         $list_groups = Yii::$app->request->post()['Group']['id'];
         // groups is required
         if (!empty($list_groups)) {
             // save client table first
             $client->save();
             // each group will be saved with a corresponding client which be saved before
             foreach ($list_groups as $key => $group) {
                 $groups_clients = new GroupClient();
                 $groups_clients->clients_id = $client->id;
                 $groups_clients->groups_id = $group;
                 $groups_clients->save();
             }
             // everything is ok, redirect to clients list page
             $errors = $groups_clients->getErrors();
             if (empty($errors)) {
                 return $this->redirect(['/clients']);
             }
         } else {
             $groups->addError('id', 'Groups can not blank');
         }
     }
     return $this->render('create', ['client' => $client, 'groups' => $groups, 'groups_clients' => $groups_clients]);
 }
开发者ID:hoangngk,项目名称:adminpanel,代码行数:34,代码来源:ClientsController.php

示例2: actionCreate

 /**
  * Creates a new Order model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $modelClient = new Client();
     $modelsOrder = [new Order()];
     if ($modelClient->load(Yii::$app->request->post())) {
         $modelsOrder = Model::createMultiple(Order::classname());
         Model::loadMultiple($modelsOrder, Yii::$app->request->post());
         // validate all models
         $valid = $modelClient->validate();
         $valid = Model::validateMultiple($modelsOrder) && $valid;
         if ($valid) {
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 if ($flag = $modelClient->save(false)) {
                     foreach ($modelsOrder as $modelOrder) {
                         $modelOrder->id_client = $modelClient->id;
                         if (!($flag = $modelOrder->save(false))) {
                             $transaction->rollBack();
                             break;
                         }
                     }
                 }
                 if ($flag) {
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $modelClient->id]);
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
             }
         }
     }
     return $this->render('create', ['modelClient' => $modelClient, 'modelsOrder' => empty($modelsOrder) ? [new Order()] : $modelsOrder]);
 }
开发者ID:earlcherry,项目名称:test-project,代码行数:38,代码来源:OrderController.php

示例3: testAge

 public function testAge()
 {
     $testObj = new Client();
     $testObj->name = "Berta";
     $testObj->age = 10;
     $this->assertFalse($testObj->save());
     $this->assertArraySubset(["age" => "Age must be greater than \"18\"."], $testObj->firstErrors);
 }
开发者ID:mvcaaa,项目名称:TestCase013,代码行数:8,代码来源:ClientTest.php

示例4: actionCreate

 /**
  * Creates a new Client model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Client();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'direction' => Direction::find()->all()]);
     }
 }
开发者ID:savers,项目名称:trip1,代码行数:14,代码来源:ClientController.php

示例5: fakeClient

 protected function fakeClient()
 {
     $fakeClient = new Client();
     $fakeClient->serial_number = "C241874";
     $fakeClient->primary_name = "Fake Client";
     $fakeClient->client_type_id = $this->fakeClientType()->client_type_id;
     $fakeClient->save();
     return $fakeClient;
 }
开发者ID:boylee1111,项目名称:Reservation,代码行数:9,代码来源:DbTestCase.php

示例6: actionCreate

 /**
  * Creates a new Client model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Client();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->clientNumber]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:AntoninSlejska,项目名称:yii-test,代码行数:14,代码来源:ClientController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['client' => 'required|unique:projects|max:255', 'image' => 'required']);
     $image = ImageuploadFacade::upload($request->file('image'));
     $project = new Client();
     $project->client = $request->input('client');
     $project->image = $image['basename'];
     $project->image_ext = $image['original_extension'];
     $project->save();
     return back();
 }
开发者ID:jardayn,项目名称:portfolio,代码行数:17,代码来源:ClientsController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     /*
     |
     | Validate input data
     |
     */
     $rules = array('id' => 'unique:clients,id', 'spamOrClient' => 'required', 'firstName' => 'required', 'state' => 'required|max:6', 'birthDate' => 'required|max:5', 'mobNum' => 'required|max:13');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         /*return redirect('clients/add')->withErrors([
               'Необходимые данные не введены, либо введены некорректно. Попробуйте еще раз!'
           ]);*/
         return redirect('clients/create')->withErrors($validator)->withInput(Input::all());
     } else {
         /*
         |
         | Create new client
         |
         */
         $newClient = new Client();
         $newClient->id = Input::get('cardID');
         $newClient->spamOrClient = Input::get('spamOrClient');
         $newClient->lastName = Input::get('lastName');
         $newClient->firstName = Input::get('firstName');
         $newClient->surName = Input::get('surName');
         $newClient->nickName = Input::get('nickName');
         $newClient->state = Input::get('state');
         $newClient->birthDate = Input::get('birthDate');
         $newClient->mobNum = Input::get('mobNum');
         $newClient->photo = Input::get('photo');
         $newClient->save();
         /*
         |
         | Putting activity into log
         |
         */
         $activityToLog = new ActivityLog();
         $activityToLog->activity = "New client created! Card №" . $newClient->id . ". Name: " . $newClient->lastName . " " . $newClient->firstName . " " . $newClient->surName;
         $activityToLog->user = \Auth::user()->name;
         $activityToLog->save();
         \Session::flash('messageClientCreated', 'Клиент создан!');
         return redirect('send/single');
     }
 }
开发者ID:viliguravlad,项目名称:tokarevsg,代码行数:50,代码来源:NewClientsController.php

示例9: anyAdd

 public function anyAdd()
 {
     $data = Request::all();
     if (count($data) > 0) {
         $UserDetails = new Client();
         $UserDetails->fullname = $data['fullname'];
         $UserDetails->email = $data['email'];
         $UserDetails->order_number = $data['order_number'];
         $UserDetails->product_id = $data['product_id'];
         $UserDetails->note = $data['note'];
         if ($UserDetails->save()) {
             $email = $data['email'];
             $subject = 'Demo mail';
             // subject you want for you email
             Session::flash('flash_message', 'successfully saved.');
             return redirect('/warranty');
         }
     }
 }
开发者ID:vinodjoshi,项目名称:laravel,代码行数:19,代码来源:ClientFrontController.php

示例10: postSignUp

 public function postSignUp(Request $request, PublicForms $publicForms, User $user, CommonCode $cCode, Client $client, Role_user $roleUser, Role $role)
 {
     $validation_rules = $publicForms->getValidationRulesSignUp();
     $this->validate($request, $validation_rules);
     $arr_request = $publicForms->getRequestArraySignup($request);
     //   	$arr_request = $admin->getRequestArray($request);
     $user->email = $arr_request['email'];
     $user->password = $arr_request['password'];
     $user->name = '';
     $user->save();
     $client->cloaked_client_id = $client->getNewCloakedClientId($user->id);
     $client->user_id = $user->id;
     $client->first_name = $arr_request['first_name'];
     $client->last_name = $arr_request['last_name'];
     $client->company = $arr_request['company'];
     $client->client_url = $arr_request['client_url'];
     $client->save();
     $bool_role_assigned = $roleUser->add_role_by_name($user->id, 'client', $role);
     $data = $publicForms->getDataArrayPostSignUp($arr_request, $user->id, $client->cloaked_client_id, $bool_role_assigned);
     return view('public/sign_up_results')->with('data', $data);
 }
开发者ID:jenniferbradley49,项目名称:server,代码行数:21,代码来源:PublicFormsController.php

示例11: post_add_user

 public function post_add_user(Request $request, Admin $admin, User $user, Client $client, CommonCode $cCode)
 {
     $validation_rules = $admin->getValidationRules();
     $this->validate($request, $validation_rules);
     $arr_request = $admin->getRequestArray($request);
     $user->email = $arr_request['email'];
     $user->password = $arr_request['password'];
     $user->name = '';
     $user->save();
     $client->cloaked_client_id = $client->getNewCloakedClientId($user->id);
     $client->user_id = $user->id;
     $client->first_name = $arr_request['first_name'];
     $client->last_name = $arr_request['last_name'];
     $client->company = $arr_request['company'];
     $client->save();
     //    	$user_id = $user->id;
     // return to raw password for view
     $arr_request['password'] = $request->password;
     $data = $admin->getDataArray($arr_request, $user->id, $client->cloaked_client_id, $this->arr_logged_in_user);
     return view('admin/add_user_results_admin')->with('data', $data);
 }
开发者ID:jenniferbradley49,项目名称:server,代码行数:21,代码来源:AdminController.php

示例12: store

 /**
  * Enregister à la base de donnée le nouveau client enregistré.
  *
  *  @return \Illuminate\Http\Response
  */
 public function store()
 {
     try {
         $input = Input::all();
         $client = new Client();
         $client->prenom = $input['prenom'];
         $client->nom = $input['nom'];
         $client->adresse = $input['adresse'];
         $client->ville = $input['ville'];
         $client->noTel = $input['noTel'];
         $client->courriel = $input['courriel'];
         $client->relation = $input['relation'];
         $client->actif = 1;
     } catch (ModelNotFoundException $e) {
         App::abort(404);
     }
     if ($client->save()) {
         return Redirect::action('ClientsController@index');
     } else {
         return Redirect::back()->withInput()->withErrors($client->validationMessages());
     }
 }
开发者ID:GBEY0402,项目名称:LesCuirsBermont3.0,代码行数:27,代码来源:ClientsController.php

示例13: getNinjaClient

 public function getNinjaClient($account)
 {
     $account->load('users');
     $ninjaAccount = $this->getNinjaAccount();
     $ninjaUser = $ninjaAccount->getPrimaryUser();
     $client = Client::whereAccountId($ninjaAccount->id)->wherePublicId($account->id)->first();
     $clientExists = $client ? true : false;
     if (!$client) {
         $client = new Client();
         $client->public_id = $account->id;
         $client->account_id = $ninjaAccount->id;
         $client->user_id = $ninjaUser->id;
         $client->currency_id = 1;
     }
     foreach (['name', 'address1', 'address2', 'city', 'state', 'postal_code', 'country_id', 'work_phone', 'language_id', 'vat_number'] as $field) {
         $client->{$field} = $account->{$field};
     }
     $client->save();
     if ($clientExists) {
         $contact = $client->getPrimaryContact();
     } else {
         $contact = new Contact();
         $contact->user_id = $ninjaUser->id;
         $contact->account_id = $ninjaAccount->id;
         $contact->public_id = $account->id;
         $contact->is_primary = true;
     }
     $user = $account->getPrimaryUser();
     foreach (['first_name', 'last_name', 'email', 'phone'] as $field) {
         $contact->{$field} = $user->{$field};
     }
     $client->contacts()->save($contact);
     return $client;
 }
开发者ID:rafaelsisweb,项目名称:invoice-ninja,代码行数:34,代码来源:AccountRepository.php

示例14: jqgrid

 public function jqgrid(Request $request)
 {
     //        return dd($request->all());
     if (Auth::check()) {
         if (in_array('ADD_EDIT_CLIENT', $this->permission)) {
             $validate = \Validator::make($request->all(), ['name' => 'required']);
             if ($validate->passes()) {
                 switch ($request->input('oper')) {
                     case 'add':
                         $audit = new AuditsController();
                         $active = 'Inactive';
                         if ($request->input('active') == 'true') {
                             $active = 'Active';
                         }
                         $client = new Client();
                         $client->name = $request->input('name');
                         $client->status = $active;
                         $client->user_id = Auth::user()->id;
                         $client->save();
                         $audit->store('client', $client->id, null, 'add');
                         return $msg = ['success' => true, 'msg' => "your Client:cl{$client->id} Added successfully"];
                         break;
                     case 'edit':
                         $client_id = $request->input('id');
                         if (User::isSuperAdmin()) {
                             $client = Client::find($client_id);
                         } else {
                             $usr_company = $this->user_company();
                             $client = Client::whereIn('user_id', $usr_company)->find($client_id);
                         }
                         if ($client) {
                             $data = array();
                             $audit = new AuditsController();
                             if ($client->name != $request->input('name')) {
                                 array_push($data, 'Name');
                                 array_push($data, $client->name);
                                 array_push($data, $request->input('name'));
                                 $client->name = $request->input('name');
                             }
                             $audit->store('client', $client_id, $data, 'edit');
                             $client->save();
                             return $msg = ['success' => true, 'msg' => "your Client:cl{$client_id} Saved saved successfully"];
                         }
                         return $msg = ['success' => false, 'msg' => "please Select your Client"];
                         break;
                 }
                 return $msg = ['success' => false, 'msg' => "Are U kidding me?"];
             }
             return $msg = ['success' => false, 'msg' => "please fill all fields"];
         }
         return $msg = ['success' => false, 'msg' => "you don\\'t have permission"];
     }
     return Redirect::to(url('user/login'));
 }
开发者ID:bluelinemango,项目名称:mango,代码行数:54,代码来源:ClientController.php

示例15: upload

 public function upload()
 {
     if ($this->validate()) {
         $isValidFormat = true;
         $isValidEncoding = true;
         if (($handle = fopen($this->csvFile->tempName, "r")) !== FALSE) {
             if (($firstLine = fgetcsv($handle)) !== FALSE) {
                 if (count($firstLine) >= 2) {
                     if (mb_detect_encoding($firstLine[0]) !== 'ASCII') {
                         $isValidEncoding = false;
                         $firstLine = $this->convert_to_ASCII($firstLine);
                     }
                 } else {
                     $isValidFormat = false;
                 }
                 if ($isValidFormat) {
                     if ($firstLine[0] !== 'client_id' || $firstLine[1] !== 'full_name' || $firstLine[2] !== 'client_type_id' || $firstLine[3] !== 'discipline_id' || $firstLine[4] !== 'active') {
                         $isValidFormat = false;
                     }
                 }
             }
             if ($isValidFormat) {
                 $success = true;
                 $row = 1;
                 while (($data = fgetcsv($handle)) !== FALSE) {
                     if (!$isValidEncoding) {
                         $data = $this->convert_to_ASCII($data);
                     }
                     $row++;
                     $model = new Client();
                     $model->client_id = $data[0];
                     $model->full_name = $data[1];
                     $model->client_type_id = $data[2];
                     $model->discipline_id = $data[3];
                     $model->active = $data[4];
                     if (!$model->save()) {
                         $idClient = Client::find()->where(['client_id' => $model->client_id])->exists();
                         $typeClient = ClientType::find()->where(['id' => $model->client_type_id])->exists();
                         $idDiscipline = Discipline::find()->where(['id' => $model->discipline_id])->exists();
                         $activo = Client::find()->where(['active' => $model->active])->exists();
                         if ($idClient == true) {
                             Yii::$app->session->addFlash("error-upload", "Error en línea: [" . $row . "] ----- El cliente con id: [" . $model->client_id . "] ya se encuentra registrado.");
                         } else {
                             if ($typeClient == false || $idDiscipline == false || $activo == false) {
                                 if ($typeClient == false) {
                                     $typeClient = "[client_type_id] No Válido. ";
                                 } else {
                                     $typeClient = "";
                                 }
                                 if ($idDiscipline == false) {
                                     $idDiscipline = "[discipline_id] No Válido. ";
                                 } else {
                                     $idDiscipline = "";
                                 }
                                 if ($activo == false) {
                                     $activo = "[active] No Válido.";
                                 } else {
                                     $activo = "";
                                 }
                                 Yii::$app->session->addFlash("error-upload", "Error en línea: [" . $row . "] ----- " . $typeClient . "" . $idDiscipline . "" . $activo . "");
                             }
                         }
                     }
                 }
                 if (!feof($handle)) {
                     $success = false;
                     Yii::$app->session->setFlash('error', Yii::t('app', 'Unexpected error.'));
                 }
             } else {
                 Yii::$app->session->setFlash('error', Yii::t('app', 'El formato del archivo No es válido. El formato válido es: ') . "<div class=\"panel panel-default\">\n\t\t\t\t\t\t\t<div class=\"panel-body\">\n\t\t\t\t\t\t\t\t<p>client_id,full_name,client_type_id,discipline_id,active</p>\n\t\t\t\t\t\t\t\t<p>98341245,Pedro Salazar Dos,1,5,1</p>\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>");
             }
             fclose($handle);
         }
         return $isValidFormat && $success;
     } else {
         return false;
     }
 }
开发者ID:rodespsan,项目名称:FMAT-SAECC,代码行数:78,代码来源:UploadIdentityData.php


注:本文中的app\models\Client::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。