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


PHP Contact::load方法代码示例

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


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

示例1: actionCreate

 public function actionCreate($type)
 {
     $incoming = new Incoming();
     $contact = new Contact();
     if ($incoming->load(Yii::$app->request->post()) && $contact->load(Yii::$app->request->post())) {
         $contact->type = Contact::PERSON;
         $isValid = $incoming->validate();
         $isValid = $contact->validate() && $isValid;
         if ($isValid) {
             $incoming->save(false);
             $contact->save(false);
             $from = new Endpoint();
             $from->type = Endpoint::FROM;
             $from->doc_id = $incoming->id;
             $from->contact_id = $contact->id;
             $from->save(false);
             return $this->redirect(['index']);
         } else {
             Yii::trace($contact->errors);
         }
     }
     $incoming->type = Incoming::PERSON;
     $incoming->docdate = date('Y-m-d');
     return $this->render('create', ['incoming' => $incoming, 'contact' => $contact]);
 }
开发者ID:kintastish,项目名称:docflow,代码行数:25,代码来源:IncomingController.php

示例2: actionCreate

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

示例3: actionCreate

 /**
  * Creates a new Contact model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Contact();
     if (!\Yii::$app->user->can('createPost', ['post' => $model])) {
         throw new NotFoundHttpException('You havent access to create item.');
     }
     $model->setScenario(Contact::SCENARIO_ADD_CONTACT);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:Konsul117,项目名称:phonebook,代码行数:18,代码来源:ContactController.php

示例4: actionCreate

 /**
  * Creates a new Contact model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Contact();
     $infoCompany = Infocompany::findOne(['id' => 1]);
     if ($model->load(Yii::$app->request->post())) {
         $model->fullname = $_POST['genderName'] . " " . $model->fullname;
         if ($model->save()) {
             //return $this->redirect(['create', 'id' => $model->id]);
             Yii::$app->session->setFlash('contactFormSubmitted');
             return $this->refresh();
         }
     } else {
         return $this->render('create', ['model' => $model, 'infoCompany' => $infoCompany]);
     }
 }
开发者ID:nguyendtu,项目名称:VietvietTravel,代码行数:20,代码来源:ContactController.php

示例5: actionCreate

 /**
  * Creates a new Contact model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @return mixed
  */
 public function actionCreate()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     // Define that response will be on json format
     $model = new Contact();
     $model->scenario = Contact::SCENARIO_CREATE;
     // Scenarios allow us to configure which attributes are safe to massive assignment
     $data = Json::decode(Yii::$app->request->post('model'));
     // First of all we decode json data to data in Yii conventions
     if ($model->load($data) && $model->save()) {
         return ['statusCode' => 200, 'model' => $model];
     } else {
         // Return error 400 if no data or not created
         return new HttpException(400);
     }
 }
开发者ID:Nemmo,项目名称:alinakz,代码行数:22,代码来源:ContactController.php

示例6: actionWorkers

 public function actionWorkers($id)
 {
     $dept = $this->loadModel($id);
     $worker = new Contact(['scenario' => Contact::SCENARIO_NEW_WORKER]);
     if ($worker->load(Yii::$app->request->post())) {
         $worker->type = Contact::COWORKER;
         $worker->dept = $dept->id;
         if ($worker->save()) {
             if ($worker->isChief) {
                 $dept->chief_id = $worker->id;
                 $dept->save();
             }
             $worker = new Contact(['scenario' => Contact::SCENARIO_NEW_WORKER]);
         }
     }
     return $this->render('workers', ['dept' => $dept, 'worker' => $worker, 'workersDataProvider' => $this->workersDataProvider($dept->id)]);
 }
开发者ID:kintastish,项目名称:docflow,代码行数:17,代码来源:DeptController.php

示例7: actionIndex

 public function actionIndex()
 {
     $model = new Contact();
     $msgs = Contact::find()->orderBy('id DESC')->limit('50')->all();
     if ($model->load(Yii::$app->request->post())) {
         $model->admin_id = Yii::$app->user->id;
         $model->time = time();
         $model->save();
         $this->redirect('contact');
     }
     // проверка на время публикации (1 час)
     $openContactForm = true;
     $restTime = 0;
     foreach ($msgs as $one) {
         if ($one['admin_id'] == Yii::$app->user->id && $one['time'] >= time() - 60 * 60) {
             $openContactForm = false;
             $restTime = ceil(($one['time'] - (time() - 60 * 60)) / 60);
             break;
         }
     }
     return $this->render('index', ['model' => $model, 'msgs' => $msgs, 'openContactForm' => $openContactForm, 'restTime' => $restTime]);
 }
开发者ID:Nechhist,项目名称:to.ru,代码行数:22,代码来源:ContactController.php

示例8: actionAddContact

 /**
  * Add a contact to an existing Supplier.
  * @param integer $id
  * @return mixed
  */
 public function actionAddContact($id)
 {
     $supplier = $this->findModel($id);
     $model = new Contact();
     $model->supplier_id = $supplier->id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $supplier->id]);
     } else {
         return $this->render('add-contact', ['model' => $model, 'supplier' => $supplier]);
     }
 }
开发者ID:stupidusername,项目名称:bukmark,代码行数:16,代码来源:SupplierController.php


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