本文整理汇总了PHP中app\models\Company::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Company::save方法的具体用法?PHP Company::save怎么用?PHP Company::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Company
的用法示例。
在下文中一共展示了Company::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store()
{
if (Session::get('level') == '1' && Session::get('fingerprint') == md5($_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'])) {
$postData = Input::All();
$messages = ['company.required' => 'กรุณากรอก'];
$rules = ['company' => 'required'];
$validator = Validator::make($postData, $rules, $messages);
if ($validator->fails()) {
return Redirect::route('company.create')->withInput()->withErrors($validator);
} else {
$data = Request::all();
$company = new Company();
$company->company = $data['company'];
$company->address = $data['address'];
$company->mobile = $data['mobile'];
$company->email = $data['email'];
DB::transaction(function () use($company) {
$company->save();
});
Session::flash('savedata', save_data);
return Redirect::to('company');
}
} else {
return Redirect::to('/');
}
}
示例2: actionCompany
public function actionCompany()
{
$company = Company::find()->one();
if (empty($company)) {
$company = new Company();
$company->vat = 0;
$company->logo = '';
}
$post = Yii::$app->request->post();
if (!empty($post)) {
if (!empty($_FILES['Company']['name']['logo'])) {
$tmp_name = $_FILES['Company']['tmp_name']['logo'];
$name = $_FILES['Company']['name']['logo'];
if (file_exists('upload/' . $name)) {
unlink('upload' . $name);
}
if (move_uploaded_file($tmp_name, 'upload/' . $name)) {
$company->logo = $name;
}
}
$company->name = $post['Company']['name'];
$company->tax_code = $post['Company']['tax_code'];
$company->tel = $post['Company']['tel'];
$company->website = $post['Company']['website'];
$company->address = $post['Company']['address'];
$company->vat = $post['Company']['vat'];
if ($company->save()) {
$session = new Session();
$session->setFlash('message', 'บันทึกรายการแล้ว');
return $this->redirect(['company']);
}
}
return $this->render('//config/company', ['company' => $company]);
}
示例3: actionCreate
/**
* Creates a new Company model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Company();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例4: postCreate
/**
* Save data from new company form.
*
* @author [Abdullah Alansari] [<ahimta@gmail.com>]
* @since [v1.8]
* @return Redirect
*/
public function postCreate()
{
$company = new Company();
$company->name = e(Input::get('name'));
if ($company->save()) {
return redirect()->to('admin/settings/companies')->with('success', trans('admin/companies/message.create.success'));
} else {
return redirect()->back()->withInput()->withErrors($company->getErrors());
}
}
示例5: actionDoadd
public function actionDoadd()
{
$company = new Company();
$company->c_name = $_POST['c_name'];
$company->c_show = $_POST['c_show'];
$company->c_desc = $_POST['c_desc'];
if ($company->save()) {
echo $this->success("添加成功", "index.php?r=company", '1');
} else {
echo $this->error("添加失败", "index.php?r=company", '1');
}
}
示例6: actionCreate
/**
* Creates a new Company model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
if (Yii::$app->user->identity->type == 'normal') {
return $this->redirect(['company/']);
}
$model = new Company();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->company_id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例7: createCompany
private function createCompany($addressID)
{
$company = new Company();
$company->created_at = date("Y-m-d H:i:s");
$company->name = $this->email;
$company->comment = "";
$company->phone = "";
$company->twenty_four_hours = 0;
$company->active = 1;
$company->status_d = 0;
$company->address_id = $addressID;
$company->save();
return $company->id;
}
示例8: actionCompany
public function actionCompany()
{
$model = new Company();
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
$model->is_sponsor = 0;
$model->is_organisator = 0;
$model->save();
Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
return $this->refresh();
}
}
return $this->render('company', ['model' => $model]);
}
示例9: openCompanies
private function openCompanies($count = 100)
{
print_r("Open companies. Count: " . $count . "...");
$this->faker->unique(true);
$buildings = Building::find()->asArray()->all();
$building_ids = ArrayHelper::getColumn($buildings, 'id');
$building_ids_length = count($building_ids) - 1;
for ($i = 0; $i < $count; $i++) {
$company = new Company();
$company->title = $this->faker->unique()->company;
$company->building_id = $building_ids[mt_rand(1, $building_ids_length)];
$company->save();
}
print_r("DONE" . PHP_EOL);
}
示例10: create_submit
public function create_submit()
{
$data = \Request::all();
$company = new Company();
$company->name = $data['name'];
if (isset($data['image'])) {
$file_name = \Common::get_img_filename($data['image']);
\Common::make_square_img($file_name, 140);
$res = \Common::s3_upload($file_name, 'company/');
if ($res['success']) {
$company->ci = $res['filename'];
}
}
$company->status = $data['status_group'];
$company->save();
return \Redirect()->action('CompanyController@index');
}
示例11: create
public function create($firstName = '', $lastName = '', $email = '', $password = '')
{
$company = new Company();
$company->utm_source = Input::get('utm_source');
$company->utm_medium = Input::get('utm_medium');
$company->utm_campaign = Input::get('utm_campaign');
$company->utm_term = Input::get('utm_term');
$company->utm_content = Input::get('utm_content');
$company->save();
$account = new Account();
$account->ip = Request::getClientIp();
$account->account_key = str_random(RANDOM_KEY_LENGTH);
$account->company_id = $company->id;
// Track referal code
if ($referralCode = Session::get(SESSION_REFERRAL_CODE)) {
if ($user = User::whereReferralCode($referralCode)->first()) {
$account->referral_user_id = $user->id;
}
}
if ($locale = Session::get(SESSION_LOCALE)) {
if ($language = Language::whereLocale($locale)->first()) {
$account->language_id = $language->id;
}
}
$account->save();
$user = new User();
if (!$firstName && !$lastName && !$email && !$password) {
$user->password = str_random(RANDOM_KEY_LENGTH);
$user->username = str_random(RANDOM_KEY_LENGTH);
} else {
$user->first_name = $firstName;
$user->last_name = $lastName;
$user->email = $user->username = $email;
if (!$password) {
$password = str_random(RANDOM_KEY_LENGTH);
}
$user->password = bcrypt($password);
}
$user->confirmed = !Utils::isNinja();
$user->registered = !Utils::isNinja() || $email;
if (!$user->confirmed) {
$user->confirmation_code = str_random(RANDOM_KEY_LENGTH);
}
$account->users()->save($user);
return $account;
}
示例12: readIni
public function readIni()
{
//new company
//
//
//get perm from ini
$encoding = "windows-1255";
//$encoding="ibm862";
$ini = $this->iniFile;
if ($fp = fopen($ini, 'r')) {
while ($line = fgets($fp)) {
@($line = iconv($encoding, "UTF-8//IGNORE", $line));
//$line=utf8_encode($line);
$type = substr($line, 0, 4);
//$obj=$this->readline($line,$type);
$obj = true;
if (!$obj) {
//$suc[$type]--;
} else {
//foreach ($obj as &$value)
// if ($encoding=="ibm862")
// $value = iconv("ISO-8859-8", "UTF-8", hebrev(iconv("UTF-8", "ISO-8859-8", $value)));
if ($type == 'A000') {
//Acc Haeder
/* Account Import */
$comp = new Company();
$comp->string = Yii::$app->dbMain->dsn;
$comp->user = Yii::$app->dbMain->username;
$comp->password = Yii::$app->dbMain->password;
/*
$obj["type"]=(int)$obj["type"]+50;
if(isset($accTypeIndex[$obj["type"]]))
$accTypeIndex[$obj["type"]]=$accTypeIndex[$obj["type"]].",".$obj["name"];
else
$accTypeIndex[$obj["type"]]=$obj["typedesc"].":".$obj["name"];
unset($obj["typedesc"]); */
//1405 acc type code
//1406 acc type name
//print_r($obj);//Yii::$app->end();
//$comp->createDb();
$comp->save();
$this->companyId = $comp->id;
$comp->readLine($line, $type);
$this->clearCompany();
//$accIndex[$obj["id"]]=$acc->save();
//get new acc index save old
//$this->companyId=$comp->id;
//echo $this->companyId;
//Yii::$app->end();
unset($comp);
}
}
}
}
}
示例13: jqgrid
public function jqgrid(Request $request)
{
// return dd($request->all());
if (Auth::check()) {
if (User::isSuperAdmin()) {
$validate = \Validator::make($request->all(), ['name' => 'required']);
if ($validate->passes()) {
switch ($request->input('oper')) {
case 'add':
$audit = new AuditsController();
$active = 'Inactive';
if ($request->input('active') == 'true') {
$active = 'Active';
}
$company = new Company();
$company->name = $request->input('name');
$company->save();
$audit->store('company', $company->id, null, 'add');
return $msg = ['success' => true, 'msg' => "your Company:cl{$company->id} Added successfully"];
break;
case 'edit':
$company_id = $request->input('id');
$company = Company::find($company_id);
if ($company) {
$data = array();
$audit = new AuditsController();
if ($company->name != $request->input('name')) {
array_push($data, 'Name');
array_push($data, $company->name);
array_push($data, $request->input('name'));
$company->name = $request->input('name');
}
$audit->store('company', $company_id, $data, 'edit');
$company->save();
return $msg = ['success' => true, 'msg' => "your Company:cl{$company_id} Saved saved successfully"];
}
break;
}
}
}
return "don't have permission";
}
return Redirect::to(url('user/login'));
}
示例14: createOrFetchCompany
/**
* Fetch an existing company, or create new if it doesn't exist
*
* @author Daniel Melzter
* @since 3.0
* @param $asset_company_name string
* @return Company
*/
public function createOrFetchCompany($asset_company_name)
{
foreach ($this->companies as $tempcompany) {
if (strcasecmp($tempcompany->name, $asset_company_name) == 0) {
$this->log('A matching Company ' . $asset_company_name . ' already exists');
return $tempcompany;
}
}
$company = new Company();
$company->name = $asset_company_name;
if (!$this->option('testrun')) {
if ($company->save()) {
$this->companies->add($company);
$this->log('Company ' . $asset_company_name . ' was created');
return $company;
} else {
$this->log('Company', $company->getErrors());
}
} else {
$this->companies->add($company);
return $company;
}
}
示例15: actionCreate
public function actionCreate()
{
//only admin
$model = new Company();
$model->string = Yii::$app->dbMain->dsn;
$model->user = Yii::$app->dbMain->username;
$model->password = Yii::$app->dbMain->password;
//$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
//$model->prefix=substr(str_shuffle($chars),0,4)."_";
if ($model->save()) {
$database = Company::findOne($model->id);
Yii::$app->session['company'] = $model->id;
//redierct to settings.
return $this->redirect(array('settings/admin'));
}
return $this->render('create', array('model' => $model));
}