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


PHP Person::save方法代码示例

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


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

示例1: store

 public function store(CreateCompanyRequest $request)
 {
     $company = Company::create($request->all());
     if (!Input::get('person_id')) {
         $person = new Person();
         $person->first_name = Input::get('person_fn');
         $person->last_name = Input::get('person_ln');
         $person->save();
     }
     $contact = new CompanyPerson();
     $contact->company_id = $company->id;
     $contact->person_id = Input::get('person_id') ? Input::get('person_id') : $person->id;
     $contact->title_id = Input::get('title_id');
     $contact->department_id = Input::get('department_id');
     $contact->phone = Input::get('phone');
     $contact->extension = Input::get('extension');
     $contact->cellphone = Input::get('cellphone');
     $contact->email = Input::get('email');
     $contact->group_type_id = Input::get('company_id') == ELETTRIC80_COMPANY_ID ? EMPLOYEE_GROUP_TYPE_ID : CUSTOMER_GROUP_TYPE_ID;
     $contact->group_id = Input::get('company_id') == ELETTRIC80_COMPANY_ID ? DEFAULT_EMPLOYEE_GROUP_ID : DEFAULT_CUSTOMER_GROUP_ID;
     $contact->save();
     $company_main_contact = new CompanyMainContact();
     $company_main_contact->company_id = $company->id;
     $company_main_contact->main_contact_id = $contact->id;
     $company_main_contact->save();
     $company_account_manager = new CompanyAccountManager();
     $company_account_manager->company_id = $company->id;
     $company_account_manager->account_manager_id = Input::get('account_manager_id');
     $company_account_manager->save();
     return redirect()->route('companies.index')->with('successes', ['company created successfully']);
 }
开发者ID:pinkynrg,项目名称:convergence2.0,代码行数:31,代码来源:CompaniesController.php

示例2: actionCreate

 /**
  * Creates a new Person model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Person();
     $address = new Address();
     if ($model->load(Yii::$app->request->post()) && $address->load(Yii::$app->request->post()) && $model->save()) {
         //            if (Yii::$app->request->isAjax)
         //                return $this->renderAjax('view', [
         //                    'model' => $model,
         //                ]);
         Yii::$app->getSession()->addFlash('success', "Запись \"{$model->fullName}\" успешно добавлена.");
         return $this->redirect(Url::previous() != Yii::$app->homeUrl ? Url::previous() : ['view', 'id' => $model->id]);
     } else {
         if (Yii::$app->request->referrer != Yii::$app->request->absoluteUrl) {
             Url::remember(Yii::$app->request->referrer ? Yii::$app->request->referrer : null);
         }
         //            if (Yii::$app->request->isAjax)
         //                return $this->renderAjax('_form', [
         //                    'model' => $model,
         //                    'address' => $address,
         //                ]);
         if (!Yii::$app->request->isPost) {
             $model->load(Yii::$app->request->get());
         }
         return $this->render('create', ['model' => $model, 'address' => $address]);
     }
 }
开发者ID:slavam,项目名称:placement,代码行数:31,代码来源:PersonController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = Request::all();
     $newData = new Person();
     $newData->first_name = isset($data['first_name']) ? $data['first_name'] : "";
     $newData->last_name = isset($data['last_name']) ? $data['last_name'] : "";
     $newData->name = isset($data['name']) ? $data['name'] : "";
     $newData->position = isset($data['position']) ? $data['position'] : "";
     $newData->address = $data['address'];
     $newData->city = isset($data['city']) ? trim(explode(',', $data['city'])[0]) : "";
     $newData->country_id = isset($data['city']) ? BackendController::getCountryID(trim(last(explode(',', $data['city'])))) : "";
     $newData->contact_number = $data['contact_number'];
     $newData->email = $data['email'];
     $newData->status = isset($data['status']) ? $data['status'] : "";
     $newData->short_text = isset($data['short_text']) ? $data['short_text'] : "";
     $newData->pic = isset($data['pic']) ? $data['pic'] : "";
     $newData->facebook = isset($data['facebook']) ? $data['facebook'] : "";
     $newData->twitter = isset($data['twitter']) ? $data['twitter'] : "";
     $newData->gplus = isset($data['gplus']) ? $data['gplus'] : "";
     $newData->created_by_users_id = Auth::id();
     if ($newData->save()) {
         $user = new User();
         $user->username = isset($data['username']) ? $data['username'] : "";
         $user->password = isset($data['username']) ? Hash::make($data['password']) : "";
         $user->email = isset($data['email']) ? $data['email'] : "";
         $user->role_id = isset($data['role']) ? $data['role'] : "";
         $user->person_id = $newData->id;
         $user->save();
         $statusCode = 200;
     } else {
         $statusCode = 422;
         //return Response::json($newData, $statusCode);
     }
     return $newData;
 }
开发者ID:armannadim,项目名称:banglafest,代码行数:40,代码来源:PersonController.php

示例4: actionCreate

 /**
  * Creates a new SocialServiceManager model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new SocialServiceManager();
     if ($model->load(Yii::$app->request->post())) {
         $person = new Person();
         $person->name = $model->name;
         $person->lastname = $model->last_name;
         $person->phone = $model->phone;
         $person->save(false);
         $user = new User();
         $user->username = $model->username;
         $user->password = $model->password;
         $user->email = $model->email;
         $user->person_id = $person->id;
         $user->scenario = 'register';
         if ($user->validate(['username', 'password'])) {
             $user->register();
             $model->user_id = $user->id;
             $model->save(false);
             //assign the role to the user
             $authManager = Yii::$app->getAuthManager();
             $socialServiceMRole = $authManager->getRole('socialServiceManager');
             $authManager->assign($socialServiceMRole, $user->id);
             //set the success message
             Yii::$app->getSession()->setFlash('success', 'Usuario creado con éxito');
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             $model->addErrors($user->errors);
         }
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:RomarioLopezC,项目名称:RobotSS,代码行数:37,代码来源:SocialServiceManagerController.php

示例5: actionCreate

 /**
  * Creates a new Student model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $student = new Student();
     $user = new User();
     $person = new Person();
     if (Yii::$app->request->post()) {
         $params = Yii::$app->request->post();
         $person->load($params);
         $user->load($params);
         $user->password_hash = Yii::$app->getSecurity()->generatePasswordHash($params['User']['password_hash']);
         $student->load($params);
         if ($person->validate() && $user->validate() && $student->validate()) {
             $person->save(false);
             $user->person_id = $person->id;
             $user->register();
             $student->user_id = $user->id;
             $student->save();
             Yii::$app->session->setFlash('success', 'Se envío un correo de confirmación. Por favor verifique su correo electrónico');
             return $this->refresh();
         } else {
             Yii::$app->session->setFlash('danger', 'Ocurrió ff un error al guardar. Vuelve a intentar');
             return $this->refresh();
         }
     } else {
         return $this->render('create', ['student' => $student, 'user' => $user, 'person' => $person]);
     }
 }
开发者ID:RomarioLopezC,项目名称:RobotSS,代码行数:32,代码来源:DefaultController.php

示例6: create

 public function create($inputs)
 {
     $person = new Person();
     $person->name = $inputs['name'];
     $person->surname = $inputs['surname'];
     $person->birthdate = $inputs['birthdate'];
     $person->save();
 }
开发者ID:morawcik,项目名称:app,代码行数:8,代码来源:PersonRepository.php

示例7: actionCreate

 /**
  * Creates a new Person model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $modelPerson = new Person();
     $modelsHouse = [new House()];
     $modelsRoom = [[new Room()]];
     if ($modelPerson->load(Yii::$app->request->post())) {
         $modelsHouse = Model::createMultiple(House::classname());
         Model::loadMultiple($modelsHouse, Yii::$app->request->post());
         // validate person and houses models
         $valid = $modelPerson->validate();
         $valid = Model::validateMultiple($modelsHouse) && $valid;
         if (isset($_POST['Room'][0][0])) {
             foreach ($_POST['Room'] as $indexHouse => $rooms) {
                 foreach ($rooms as $indexRoom => $room) {
                     $data['Room'] = $room;
                     $modelRoom = new Room();
                     $modelRoom->load($data);
                     $modelsRoom[$indexHouse][$indexRoom] = $modelRoom;
                     $valid = $modelRoom->validate();
                 }
             }
         }
         if ($valid) {
             $transaction = Yii::$app->db->beginTransaction();
             try {
                 if ($flag = $modelPerson->save(false)) {
                     foreach ($modelsHouse as $indexHouse => $modelHouse) {
                         if ($flag === false) {
                             break;
                         }
                         $modelHouse->person_id = $modelPerson->id;
                         if (!($flag = $modelHouse->save(false))) {
                             break;
                         }
                         if (isset($modelsRoom[$indexHouse]) && is_array($modelsRoom[$indexHouse])) {
                             foreach ($modelsRoom[$indexHouse] as $indexRoom => $modelRoom) {
                                 $modelRoom->house_id = $modelHouse->id;
                                 if (!($flag = $modelRoom->save(false))) {
                                     break;
                                 }
                             }
                         }
                     }
                 }
                 if ($flag) {
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $modelPerson->id]);
                 } else {
                     $transaction->rollBack();
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
             }
         }
     }
     return $this->render('create', ['modelPerson' => $modelPerson, 'modelsHouse' => empty($modelsHouse) ? [new House()] : $modelsHouse, 'modelsRoom' => empty($modelsRoom) ? [[new Room()]] : $modelsRoom]);
 }
开发者ID:inamjung,项目名称:testupgithup,代码行数:62,代码来源:PersonController.php

示例8: actionCreate

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

示例9: actionCreate

 /**
  * Creates a new Person model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Person();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('alert', ['body' => \Yii::t('app', 'Person {name} was created', ['name' => Html::a($model->getFullName(), Url::toRoute(['view', 'id' => $model->id]))]), 'options' => ['class' => 'alert-success']]);
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:sergeybardier,项目名称:sbtest,代码行数:15,代码来源:PersonController.php

示例10: addPerson

 /**
  * Define custom actions here
  * @param $firstName
  * @param $lastName
  * @param $parental
  * @param $gender
  * @return Person
  */
 public function addPerson($firstName, $lastName, $parental, $gender)
 {
     $person = new Person();
     $person->first_name = $firstName;
     $person->last_name = $lastName;
     $person->parental = $parental;
     $person->gender = $gender;
     $person->save();
     return $person;
 }
开发者ID:sabahtalateh,项目名称:familyeditor,代码行数:18,代码来源:FunctionalTester.php

示例11: store

 public function store(Requests\StorePersonRequest $request)
 {
     $person = new Person();
     $person->first_name = $request->get('first_name');
     $person->last_name = $request->get('last_name');
     $person->parental = $request->get('parental');
     $person->gender = $request->get('gender');
     $person->save();
     flash()->success('Вы добавили ' . $person->first_name);
     return Redirect::route('person.list');
 }
开发者ID:sabahtalateh,项目名称:familyeditor,代码行数:11,代码来源:PersonController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make(Request::all(), ['name' => 'required']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator->errors());
     } else {
         try {
             $person = new Person();
             $person->name = Input::get('name');
             $person->last_name = Input::get('last_name');
             $person->document = Input::get('document') == '' ? null : Input::get('document');
             $person->identity = Input::get('identity') == '' ? null : Input::get('identity');
             $person->email = Input::get('email') == '' ? null : Input::get('email');
             $person->birthdate = Input::get('birthdate');
             $person->nationality = Input::get('nationality');
             $person->gender = Input::get('gender');
             $person->phone = Input::get('phone');
             $person->phone_cel = Input::get('phone_cel');
             $person->name = Input::get('name');
             $person->name = Input::get('name');
             $person->save();
             $member = new Member();
             $member->father = Input::get('father');
             $member->mother = Input::get('mother');
             $member->marital_status_id = Input::get('marital_status_id');
             $member->date_baptism = Input::get('date_baptism');
             $member->occupacion = Input::get('occupacion');
             $member->function_id = Input::get('function_id');
             $member->literacy_id = Input::get('literacy_id');
             $member->person_id = $person->id;
             $member->save();
             $address = new Address();
             $address->address = Input::get('address');
             $address->number = Input::get('number');
             $address->complement = Input::get('complement');
             $address->zip_code = Input::get('zip_code');
             $address->reference = Input::get('reference');
             $address->country = Input::get('country');
             $address->state = Input::get('state');
             $address->city = Input::get('city');
             $address->person_id = $person->id;
             $address->save();
             return redirect('members');
         } catch (\Illuminate\Database\QueryException $e) {
             print_r($e->errorInfo);
         }
     }
 }
开发者ID:igormoura,项目名称:ecclesia,代码行数:54,代码来源:MemberController.php

示例13: actionAddFamilyMember

 public function actionAddFamilyMember()
 {
     $this->layout = 'frontend';
     // $searchModel = new SearchPerson();
     $user = new Person();
     $user->scenario = 'add-family';
     // Set Family ID
     $user->family_id = Yii::$app->user->identity->id;
     if ($user->load(Yii::$app->request->post()) && $user->validate()) {
         $user->active = 1;
         if ($user->save()) {
             $user->image = \yii\web\UploadedFile::getInstances($user, 'image');
             $user->uploadPhotos();
             Yii::$app->session->setFlash('success', 'Profile successfully updated');
             return $this->redirect(['/']);
         }
     }
     return $this->render('family-member-form', ['user' => $user]);
 }
开发者ID:jcshep,项目名称:FrontRunner,代码行数:19,代码来源:PersonController.php

示例14: actionCreate

 public function actionCreate()
 {
     if (count($_POST) > 0) {
         $personInfo = ['firstname' => strtolower(\Yii::$app->request->post('firstname')), 'lastname' => strtolower(\Yii::$app->request->post('lastname')), 'dob' => date('Y-m-d', strtotime(\Yii::$app->request->post('dob'))), 'zip' => \Yii::$app->request->post('zip')];
         $person = new Person($personInfo);
         $saved = $person->save();
         if (!$saved) {
             $errors = $person->getErrors();
             foreach ($errors as $messages) {
                 foreach ($messages as $message) {
                     \Yii::$app->session->addFlash('danger', $message);
                 }
             }
             header("Location: /persons/web/add");
             exit;
         }
         \Yii::$app->session->addFlash('success', 'Record added successfully.');
         header("Location: /persons/web/person/{$person->id}");
         exit;
     }
     return $this->render('create');
 }
开发者ID:jrss95,项目名称:persons,代码行数:22,代码来源:SiteController.php

示例15: store

 public function store(CreateCompanyPersonRequest $request)
 {
     if (!Input::get('person_id')) {
         $person = new Person();
         $person->first_name = Input::get('person_fn');
         $person->last_name = Input::get('person_ln');
         $person->save();
     }
     $contact = new CompanyPerson();
     $contact->company_id = Input::get('company_id');
     $contact->person_id = Input::get('person_id') ? Input::get('person_id') : $person->id;
     $contact->department_id = Input::get('department_id');
     $contact->division_ids = is_array(Input::get('division_ids')) ? implode(",", Input::get('division_ids')) : NULL;
     $contact->title_id = Input::get('title_id');
     $contact->phone = Input::get('phone');
     $contact->extension = Input::get('extension');
     $contact->cellphone = Input::get('cellphone');
     $contact->email = Input::get('email');
     $contact->group_type_id = Input::get('company_id') == ELETTRIC80_COMPANY_ID ? EMPLOYEE_GROUP_TYPE_ID : CUSTOMER_GROUP_TYPE_ID;
     $contact->group_id = Input::get('company_id') == ELETTRIC80_COMPANY_ID ? DEFAULT_EMPLOYEE_GROUP_ID : DEFAULT_CUSTOMER_GROUP_ID;
     $contact->save();
     return redirect()->route('company_person.index')->with('successes', ['Contact created successfully']);
 }
开发者ID:pinkynrg,项目名称:convergence2.0,代码行数:23,代码来源:CompanyPersonController.php


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