本文整理汇总了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);
}
示例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');
}
示例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));
}
示例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();
}
示例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
}
示例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();
}
}
示例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());
};
}
示例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));
}
示例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);
}
}
示例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;
}
}
示例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;
}
}
示例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();
}
}
示例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"));
}
示例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));
}
示例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));
}