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


PHP Company::save方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), array('name' => 'required', 'description' => 'required', 'url' => 'required|url', 'photo' => 'required|image'));
     if ($validator->fails()) {
         return Response::json($validator->messages(), 400);
     }
     $company = new Company();
     $company->name = Input::get('name');
     $company->description = Input::get('description');
     $company->url = Input::get('url');
     //temporary for territory
     $company->territory_id = 1;
     $company->save();
     //save category and tags if available
     foreach (Input::get('category') as $catid) {
         $company->categories()->attach($catid);
     }
     foreach (Input::get('tag') as $tagid) {
         $company->tags()->attach($tagid);
     }
     $image = Input::file('photo');
     $filename = $company->id;
     $saveBigUrl = base_path() . '/public/images/companies/' . $filename . '.jpg';
     $saveMediumUrl = base_path() . '/public/images/companies/' . $filename . '_medium.jpg';
     $saveSmallUrl = base_path() . '/public/images/companies/' . $filename . '_small.jpg';
     Image::make($image->getRealPath())->fit(600, null, function ($constraint) {
         //for big image
         $constraint->upsize();
     })->save($saveBigUrl, 50)->fit(300)->save($saveMediumUrl, 50)->fit(100)->save($saveSmallUrl, 50);
     $company->big_image_url = url('images/companies/' . $filename . '.jpg');
     $company->medium_image_url = url('images/companies/' . $filename . '_medium.jpg');
     $company->small_image_url = url('images/companies/' . $filename . '_small.jpg');
     $company->save();
     return Response::json(array('success_code' => 'OK', 'data' => $company->toArray()), 201);
 }
开发者ID:rhalff,项目名称:vdragon-api,代码行数:40,代码来源:CompanyController.php

示例2: testSave

 public function testSave()
 {
     $c = new Company();
     $c->name = 'Model Persister Company 2';
     $c->save();
     $this->assertNotNull($c->id);
     $c->name = 'Model Persister Company 2 updated';
     $c->save();
     $c2 = Company::find($c->id);
     $this->assertEquals($c2->name, 'Model Persister Company 2 updated');
 }
开发者ID:scandio,项目名称:troba,代码行数:11,代码来源:ModelPersistersTest.php

示例3: 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

示例4: store

 /**
  * Store a newly created resource in storage.
  * POST /debtors
  *
  * @return Response
  */
 public function store()
 {
     $contact = new Contact();
     $contact->name = Input::get('contact_person');
     $contact->email = Input::get('email');
     $contact->phone = Input::get('phone');
     $contact->mobile = Input::get('mobile');
     $contact->web = Input::get('web');
     $contact->fax = Input::get('fax');
     $contact->save();
     $contact_id = $contact->id;
     $company = new Company();
     $company->name = Input::get('company_name');
     $company->contact_id = $contact_id;
     $company->address = Input::get('address');
     $company->postal_code = Input::get('postal_code');
     $company->city = Input::get('city');
     $company->country = Input::get('country');
     $company->vat = Input::get('vat');
     $company->coc = Input::get('coc');
     $company->save();
     $company_id = $company->id;
     //Billing
     $contact_billing = new Contact();
     $contact_billing->name = Input::get('billing_contact_person');
     $contact_billing->billing = 'true';
     $contact_billing->save();
     $contact_billing_id = $contact_billing->id;
     $company_billing = new Company();
     $company_billing->name = Input::get('billing_company_name');
     $company_billing->contact_id = $contact_billing_id;
     $company_billing->address = Input::get('billing_address');
     $company_billing->postal_code = Input::get('billing_postal_code');
     $company_billing->city = Input::get('billing_city');
     $company_billing->country = Input::get('billing_country');
     $contact_billing->billing = 'true';
     $company_billing->save();
     $company_billing_id = $contact_billing->id;
     $bank = new Bank();
     $bank->name = Input::get('bank');
     $bank->bic = Input::get('bic');
     $bank->save();
     $bank_id = $bank->id;
     $account = new Account();
     $account->iban = Input::get('iban');
     $account->name = Input::get('account_name');
     $account->bank_id = $bank_id;
     $account->save();
     $account_id = $account->id;
     //Debtor Save
     $debtor = new Debtor();
     $debtor->no = Input::get('debtor_number');
     $debtor->legal = Input::get('legal');
     $debtor->company_id = $company_id;
     $debtor->billing_company_id = $company_billing_id;
     $debtor->account_id = $account_id;
     $debtor->group_id = Input::get('group');
     $debtor->save();
     return $this->index();
 }
开发者ID:BQumobile,项目名称:simple-invoicing-system,代码行数:66,代码来源:DebtorsController.php

示例5: archive

 /**
  * Archive / unarchive this company
  *
  * @param void
  * @return null
  */
 function archive()
 {
     if ($this->active_company->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_company->canArchive($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN, null);
     }
     // if
     if ($this->request->isSubmitted()) {
         $new_value = (bool) $this->request->get('set_value');
         if ($new_value) {
             $success_message = lang('":name" has been successfully archived', array('name' => $this->active_company->getName()));
             $error_message = lang('Failed to archive ":name"', array('name' => $this->active_company->getName()));
         } else {
             $success_message = lang('":name" has been successfully moved from archive to the list of active companies', array('name' => $this->active_company->getName()));
             $error_message = lang('Failed to move ":name" from the archive to the list of active companies', array('name' => $this->active_company->getName()));
         }
         // if
         $this->active_company->setIsArchived($new_value);
         $save = $this->active_company->save();
         if ($save && !is_error($save)) {
             flash_success($success_message);
         } else {
             flash_error($error_message);
         }
         // if
         $this->redirectToUrl($this->active_company->getViewUrl());
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:40,代码来源:CompaniesController.class.php

示例6: createAndSaveMultipleCompanies

 public function createAndSaveMultipleCompanies($count)
 {
     for ($i = 65; $i <= 65 + $count - 1; $i++) {
         $company = new Company();
         $company->setName(sprintf($this->getCreatedCompanynamePattern(), chr($i)));
         $company->save();
     }
 }
开发者ID:rmhdev,项目名称:sfSesame,代码行数:8,代码来源:CompanyTestFunctional.class.php

示例7: add

 public static function add()
 {
     return function ($request, $response) {
         $data = $request->data();
         $model = new Company();
         $model->name = $data->name;
         $model->description = $data->description;
         $model->save();
         $response->json($model->as_array());
     };
 }
开发者ID:samdubey,项目名称:ads2,代码行数:11,代码来源:companyctrl.php

示例8: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Company();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Company'])) {
         $model->attributes = $_POST['Company'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:kenrestivo,项目名称:ossasep,代码行数:17,代码来源:CompanyController.php

示例9: store

 public function store()
 {
     $rules = ['name' => 'required', 'vat_number' => 'required', 'address' => 'required', 'postal_code' => 'required', 'email' => 'required|email', 'phone' => 'required', 'category_id' => 'required', 'city_id' => 'required'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $password = Input::get('password');
         if (Input::has('company_id')) {
             $id = Input::get('company_id');
             $company = CompanyModel::find($id);
             if ($password !== '') {
                 $company->secure_key = md5($company->salt . $password);
             }
         } else {
             $company = new CompanyModel();
             if ($password === '') {
                 $alert['msg'] = 'You have to enter password';
                 $alert['type'] = 'danger';
                 return Redirect::route('admin.company.create')->with('alert', $alert);
             }
             $company->salt = str_random(8);
             $company->token = str_random(8);
             $company->secure_key = md5($company->salt . $password);
         }
         $company->name = Input::get('name');
         $company->vat_number = Input::get('vat_number');
         $company->address = Input::get('address');
         $company->postal_code = Input::get('postal_code');
         $company->email = Input::get('email');
         $company->phone = Input::get('phone');
         $company->category_id = Input::get('category_id');
         $company->city_id = Input::get('city_id');
         $company->save();
         if (!Input::has('company_id')) {
             $setting = new SettingModel();
             $setting->company_id = $company->id;
             $setting->waiting_time = WAITING_TIME;
             $setting->logo = LOGO;
             $setting->color = COLOR;
             $setting->background = BACKGROUND;
             $setting->start_time = START_TIME;
             $setting->end_time = END_TIME;
             $setting->save();
             File::makeDirectory(public_path() . "/assets/img/stores/" . $company->id, 0775, true, true);
         }
         $alert['msg'] = 'Company has been saved successfully';
         $alert['type'] = 'success';
         return Redirect::route('admin.company')->with('alert', $alert);
     }
 }
开发者ID:victory21th,项目名称:QM-Laravel,代码行数:51,代码来源:CompanyController.php

示例10: register

 /**
  * create new company & user as creator & admin
  */
 public function register()
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         //create company first
         $company = new Company();
         $company->name = $this->name;
         $company->country = $this->country;
         $company->phone = $this->phone;
         if (!$company->save()) {
             $transaction->rollback();
             return false;
         }
         //create user
         $user = new User();
         $user->username = $this->username;
         $user->password = $user->encrypt($this->password);
         $user->password_repeat = $this->password_repeat;
         $user->email = $this->email;
         $user->company_id = $company->id;
         $user->create_time_utc = $user->update_time_utc = time();
         if (!$user->save(false)) {
             $transaction->rollback();
             return false;
         }
         $company->owner_id = $company->create_user_id = $company->update_user_id = $user->id;
         if (!$company->update()) {
             $transaction->rollback();
             return false;
         }
         $user->create_user_id = $user->update_user_id = $user->id;
         if (!$user->update()) {
             $transaction->rollback();
             return false;
         }
         //create default product folder
         $defaultProductFolder = new ProductFolder();
         $defaultProductFolder->name = 'Main Folder';
         $defaultProductFolder->parent_id = 0;
         $defaultProductFolder->company_id = $company->id;
         if (!$defaultProductFolder->save()) {
             $transaction->rollback();
             return false;
         }
         $transaction->commit();
         return true;
     } catch (Exception $ex) {
         $transaction->rollback();
         return false;
     }
 }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:54,代码来源:RegisterForm.php

示例11: createUser

 public function createUser(RegistrationForm $form)
 {
     $transaction = Yii::app()->getDb()->beginTransaction();
     try {
         $user = new User();
         $password = rand(1000000, 9999999);
         $Company = new Company();
         if ($form->organization_name) {
             $Company->name = $form->organization_name;
         }
         $Company->create = new CDbExpression('NOW()');
         $Company->save();
         $user->email = $form->email;
         $user->contact_phone = $form->phone;
         $user->contact_phone_prefix = $form->prefphone;
         $user->company_id = $Company->id;
         $user->status = User::STATUS_ACTIVE;
         //Сделать автопроверку выписки
         $user->setAttribute('hash', $this->hasher->hashPassword($password));
         if ($user->save() && ($token = $this->tokenStorage->createAccountActivationToken($user)) !== false) {
             $user->sendCRMRegistration();
             User::savePost($user);
             \Yii::import('application.modules.rbac.models.*');
             $model = new AuthAssignment();
             //$model->setAttributes(['userid' => $user->id,'itemname' => 'standart']); //Назаначаем роль владельца компании без инн
             //                $model->setAttributes(['userid' => $user->id,'itemname' => 'own_wo_inn']); //Назаначаем роль владельца компании без инн
             $model->setAttributes(['userid' => $user->id, 'itemname' => 'owner']);
             //Назаначаем роль владельца компании без инн
             if (!$model->save()) {
                 throw new CDbException(Yii::t('UserModule.rbac', 'There is an error occurred when saving data!'));
             }
             Yii::app()->eventManager->fire(UserEvents::SUCCESS_REGISTRATION, new UserRegistrationEvent($form, $user, $token, $password));
             Yii::log(Yii::t('UserModule.user', 'Account {nick_name} was created', ['{nick_name}' => $user->email]), CLogger::LEVEL_INFO, UserModule::$logCategory);
             $transaction->commit();
             $LoginForm = new LoginForm();
             $LoginForm->email = $user->email;
             $LoginForm->password = $password;
             Yii::app()->authenticationManager->login($LoginForm, Yii::app()->getUser(), Yii::app()->getRequest());
             return $user;
         }
         throw new CException(Yii::t('UserModule.user', 'Error creating account!'));
     } catch (Exception $e) {
         Yii::log(Yii::t('UserModule.user', 'Error {error} account creating!', ['{error}' => $e->__toString()]), CLogger::LEVEL_INFO, UserModule::$logCategory);
         $transaction->rollback();
         Yii::app()->eventManager->fire(UserEvents::FAILURE_REGISTRATION, new UserRegistrationEvent($form, $user));
         return false;
     }
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:48,代码来源:UserManager.php

示例12: store

 public function store()
 {
     $input = Input::all();
     $company = new Company();
     $company->company_name = $input['company_name'];
     $company->company_address = $input['company_address'];
     $company->user_id = Auth::user()->id;
     $rules = array('company_name' => 'required', 'company_address' => 'required');
     $validation = Validator::make($input, $rules);
     if ($validation->passes()) {
         $company->save();
         return View::make('project.projectCreate');
     } else {
         return Redirect::to('companyCreate')->withErrors($validation)->withInput();
     }
 }
开发者ID:s2885117,项目名称:geoinfo,代码行数:16,代码来源:CompanyController.php

示例13: createAction

 /**
  * Creates a new company
  */
 public function createAction()
 {
     if (!$this->request->isPost()) {
         return $this->dispatcher->forward(array("controller" => "company", "action" => "index"));
     }
     $company = new Company();
     $company->setId($this->request->getPost("id"));
     $company->setName($this->request->getPost("name"));
     if (!$company->save()) {
         foreach ($company->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->dispatcher->forward(array("controller" => "company", "action" => "new"));
     }
     $this->flash->success("company was created successfully");
     return $this->dispatcher->forward(array("controller" => "company", "action" => "index"));
 }
开发者ID:andresfranco,项目名称:Phalcontest,代码行数:20,代码来源:CompanyController.php

示例14: actionCreate

 public function actionCreate()
 {
     if (isset($_POST['company_to_copy']) && $_POST['company_to_copy']) {
         $copy_data_list = array('Templates', 'Сatalog', 'ProjectStatus', 'PartStatus', 'ProjectFields', 'ProfilesFields');
         $prefix = intval($_POST['company_to_copy']) . '_';
         $model = new Company();
         $model->organization = 1;
         $model->name = 'New company';
         $model->domains = 'new.company.admintrix.com';
         $model->language = 'en';
         $model->supportEmail = 'support@new.company.admintrix.com';
         $model->PaymentCash = 1;
         $model->save();
         $new_prefix = $model->id . '_';
         $s = strlen($prefix);
         $result = Yii::app()->db->createCommand('SHOW TABLES;')->queryAll();
         foreach ($result as $item) {
             if (strpos($item[key($item)], $prefix) === 0) {
                 $list[] = substr($item[key($item)], $s);
             }
         }
         foreach ($list as $table) {
             $sql = 'CREATE TABLE `' . $new_prefix . $table . '` LIKE `' . $prefix . $table . '`;';
             Yii::app()->db->createCommand($sql)->execute();
             if (in_array($table, $copy_data_list)) {
                 $sql = 'INSERT `' . $new_prefix . $table . '` SELECT * FROM `' . $prefix . $table . '`;';
                 Yii::app()->db->createCommand($sql)->execute();
             }
         }
         /*
         $sql = 'CREATE TABLE `'.$new_prefix.'Users'.'` LIKE `'.$prefix.'Users'.'`;';
         Yii::app()->db->createCommand($sql)->execute();
         $sql = 'CREATE TABLE `'.$new_prefix.'AuthAssignment'.'` LIKE `'.$prefix.'AuthAssignment'.'`;';
         Yii::app()->db->createCommand($sql)->execute();
         */
         $sql = 'INSERT INTO `' . $new_prefix . 'Users` (`username`,`password`,`email`,`superuser`,`status`) VALUES ("admin","' . UserModule::encrypting('admin') . '","admin@new.company.admintrix.com",1,1);';
         Yii::app()->db->createCommand($sql)->execute();
         $sql = 'INSERT INTO `' . $new_prefix . 'AuthAssignment` (`itemname`,`userid`) VALUES ("Admin",1);';
         Yii::app()->db->createCommand($sql)->execute();
         $this->redirect(array('edit', 'id' => $model->id));
     }
     $companies = Company::getList();
     //Yii::app()->theme = 'admin';
     $this->render('create', array('companies' => $companies));
 }
开发者ID:akoch-ov,项目名称:dipstart-development,代码行数:45,代码来源:CompanyController.php

示例15: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Company();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Company'])) {
         $model->attributes = $_POST['Company'];
         $model->ref = Company::createRef();
         if (isset($_GET['ref'])) {
             $ref = $_GET['ref'];
             $model->parent_id = Company::findParent($ref);
         }
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:griffindor,项目名称:new-inventory,代码行数:22,代码来源:CompanyController.php


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