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


PHP Company::validate方法代码示例

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


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

示例1: actionAddcompany

 public function actionAddcompany()
 {
     $companyModel = new Company();
     $userLoginModel = new UserLogin();
     $userProfileModel = new UserProfile();
     if (isset($_POST['Company'])) {
         $companyModel->attributes = $_POST['Company'];
         $userLoginModel->attributes = $_POST['UserLogin'];
         $userProfileModel->attributes = $_POST['UserProfile'];
         if ($companyModel->validate()) {
             if ($companyModel->save()) {
                 $userLoginModel->UserRoleID = 2;
                 // $userLoginModel->LoginEmail = 'addeduser@test.com';
                 $userLoginModel->UserPassword = md5($userLoginModel->UserPassword);
                 $userLoginModel->IsPasswordReset = 1;
                 $userLoginModel->IsActive = 1;
                 $userLoginModel->save();
                 $userProfileModel->UserLoginID = $userLoginModel->UserLoginID;
                 $userProfileModel->CompanyID = $companyModel->CompanyID;
                 // $userProfileModel->FirstName = 'Test';
                 // $userProfileModel->LastName = 'test';
                 $userProfileModel->AgreeToTerms = 0;
                 $userProfileModel->IsFacilitator = 0;
                 $userProfileModel->save();
                 $this->redirect(Yii::app()->createUrl('admin/setup', array('id' => $companyModel->CompanyID)));
             }
         }
     }
     $this->render('add-company', array('companyModel' => $companyModel, 'userLoginModel' => $userLoginModel, 'userProfileModel' => $userProfileModel));
 }
开发者ID:elephanthead,项目名称:itr,代码行数:30,代码来源:AdminController.php

示例2: doValidate

 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aCategory !== null) {
             if (!$this->aCategory->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
             }
         }
         if ($this->aElementStatus !== null) {
             if (!$this->aElementStatus->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aElementStatus->getValidationFailures());
             }
         }
         if ($this->aCompany !== null) {
             if (!$this->aCompany->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aCompany->getValidationFailures());
             }
         }
         if (($retval = ElementPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         if ($this->collPreferences !== null) {
             foreach ($this->collPreferences as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collOrders !== null) {
             foreach ($this->collOrders as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collElementFiles !== null) {
             foreach ($this->collElementFiles as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
开发者ID:Chipusy,项目名称:lkbroker,代码行数:63,代码来源:BaseElement.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'show' page.
  */
 public function actionCreate()
 {
     $model = new Company($this->action->id);
     if (isset($_POST['Company'])) {
         // collect user input data
         $model->attributes = $_POST['Company'];
         // validate with the current action as scenario and save without validation
         if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
             if (isset($_POST['User2Company'])) {
                 // assigned users
                 $model->allUser2Company = array(0 => new User2Company('create'));
                 //createCompany
                 $model->allUser2Company[0]->companyId = $model->id;
                 foreach ($model->allUser2Company as $user2Company) {
                     $user2Company->attributes = $_POST['User2Company'];
                     $user2Company->position = 'owner';
                     $user2Company->save();
                 }
             }
             if (isset($_POST['Location'])) {
                 // assigned locations
                 $model->allLocation = array(0 => new Location('reate'));
                 foreach ($model->allLocation as $location) {
                     // collect user input data
                     $location->attributes = $_POST['Location'];
                     // validate and create/update record
                     if ($location->save()) {
                         $location2Record = new Location2Record('create');
                         $location2Record->locationId = $location->id;
                         $location2Record->record = get_class($model);
                         $location2Record->recordId = $model->id;
                         $location2Record->save();
                     }
                 }
             }
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', 'The new "{title}" company record has been successfully created.', array('{title}' => MHtml::wrapInTag($model->title, 'strong'))));
             // go to the 'show' page
             $this->redirect(array('show', 'id' => $model->id));
         }
     } else {
         // pre-assigned attributes (default values for a new record)
         $model->isActive = Company::IS_ACTIVE;
     }
     if (!isset($model->allUser2Company[0])) {
         // new associated user
         $model->allUser2Company = array(0 => new User2Company('create'));
     }
     $model->allUser2Company[0]->companyId = $model->id;
     if (!isset($model->allLocation[0])) {
         // new associated location
         $model->allLocation = array(0 => new Location('create'));
     }
     // display the create form
     $this->render($this->action->id, array('model' => $model));
 }
开发者ID:megabr,项目名称:web3cms,代码行数:60,代码来源:CompanyController.php

示例4: saveOrder

 public function saveOrder()
 {
     $inputShipFrom = Input::get('shipFrom');
     $inputShipFrom = $this->jsonToInputArray($inputShipFrom);
     $inputshipTo = Input::get('shipTo');
     $inputshipTo = $this->jsonToInputArray($inputshipTo);
     $inputItem = Input::get('itemDetail');
     $inputItem = $this->jsonToInputArray($inputItem);
     $inputCompany = Input::get('companyInfo');
     $inputCompany = $this->jsonToInputArray($inputCompany);
     $result = array('errors' => '', 'result' => '');
     $foundErrors = false;
     //validate ship from info.
     $shipFrom = new ShipFrom();
     if ($shipFrom->validate($inputShipFrom) === false) {
         $foundErrors = true;
         $messages = $shipFrom->messages();
         if (count($messages)) {
             foreach ($messages as $message) {
                 $result['errors'] .= "<li>{$message}</li>";
             }
         }
     }
     //validate ship to information
     $shipTo = new ShipTo();
     if ($shipTo->validate($inputshipTo) === false) {
         $foundErrors = true;
         $messages = $shipTo->messages();
         if (count($messages)) {
             foreach ($messages as $message) {
                 $result['errors'] .= "<li>{$message}</li>";
             }
         }
     }
     //validate item information
     $item = new Item();
     if ($item->validate($inputItem) === false) {
         $foundErrors = true;
         $messages = $item->messages();
         if (count($messages)) {
             foreach ($messages as $message) {
                 $result['errors'] .= "<li>{$message}</li>";
             }
         }
     }
     //validate company information
     $company = new Company();
     if ($company->validate($inputCompany) === false) {
         $foundErrors = true;
         $messages = $company->messages();
         if (count($messages)) {
             foreach ($messages as $message) {
                 $result['errors'] .= "<li>{$message}</li>";
             }
         }
     }
     if ($foundErrors == true) {
         echo json_encode($result);
         return;
     }
     $data = array('shipFrom' => $inputShipFrom, 'shipTo' => $inputshipTo, 'item' => $inputItem, 'company' => $inputCompany);
     $action = Input::get('action');
     if ($action == 'update') {
         $orderId = Input::get('order_id');
         if (Order::update($orderId, $data) == true) {
             $result['result'] = 'success';
         } else {
             $result['errors'] = "<li>There was a problem with record update.Please try later.</li>";
         }
     } else {
         //create new order
         $newOrderId = Order::insert($data);
         if (is_numeric($newOrderId) && $newOrderId > 0) {
             $result['result'] = 'success';
         }
     }
     echo json_encode($result);
 }
开发者ID:yousafmalik786,项目名称:shipping-crud,代码行数:78,代码来源:OrderController.php

示例5: beforeSave

 /**
  * Before model saved
  *
  * @return bool
  */
 public function beforeSave()
 {
     // Save new company, if id is not numeric then user added a custom value
     $company = Company::model()->countByAttributes(['id' => $this->company_id]);
     if ($company == 0) {
         $company = new Company();
         $company->setAttribute('title', $this->company_id);
         if (!$company->validate()) {
             $this->addErrors($company->getErrors());
         } else {
             if ($company->save()) {
                 $this->company_id = $company->id;
             } else {
                 $this->addError('company_id', [Yii::t('main', 'Error saving new company.')]);
             }
         }
     }
     // If model is updating
     if (!$this->isNewRecord) {
         $this->beforeUpdate();
     }
     return parent::beforeSave();
 }
开发者ID:septembermd,项目名称:n1,代码行数:28,代码来源:User.php

示例6: Company

include "header.php";
$company = new Company();
try {
    if (!$user->level) {
        throw new LoginException("You must be logged in to use this feature.");
    }
    if ($user->level < 2) {
        throw new LoginException("You do not have permission to use this feature.  Please log into the Administrator account.");
    }
    list($company->name, $company->address, $company->city, $company->state, $company->zip, $company->phone, $company->logo) = $input->getInputValues('name', 'address', 'city', 'state', 'zip', 'phone', 'logo');
    $id = $company->exists();
    if ($id) {
        $company->id = $id;
    }
    if ($company->name) {
        $company->validate();
        if ($company->save()) {
            flash("Company Information Updated");
        } else {
            throw new Exception("Could Not Save To Database.");
        }
    } else {
        if ($id) {
            $company->load($id);
        }
    }
    include "../views/companyinfo.php";
} catch (LoginException $e) {
    $redirect = "companyinfo.php";
    include "../views/login.php";
    throw $e;
开发者ID:carriercomm,项目名称:Sipen-CMS,代码行数:31,代码来源:companyinfo.php


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