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


PHP Manufacturer::save方法代码示例

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


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

示例1: actionCreate

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

示例2: actionCreate

 public function actionCreate()
 {
     IsAuth::Admin();
     $model = new Manufacturer();
     if (isset($_POST['Manufacturer'])) {
         $model->attributes = $_POST['Manufacturer'];
         $model->date_added = new CDbExpression('NOW()');
         $model->date_modified = new CDbExpression('NULL');
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->manufacturer_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:tierous,项目名称:yiirisma,代码行数:14,代码来源:ManufacturerController.php

示例3: save

 public function save()
 {
     $manufacturer = Manufacturer::model()->findByPk($this->id);
     if (is_null($manufacturer)) {
         // is insert
         $manufacturer = new Manufacturer();
     }
     $manufacturer->name = $this->name;
     $manufacturer->image = $this->image;
     $manufacturer->sort_order = $this->sortOrder;
     $manufacturer->save();
     // SEO Keyword
     $manufacturer->updateSEOKeyword($this->seoKeyword);
     // Stores
     $manufacturer->clearAllStoresRelations();
     if (isset($this->stores) && count($this->stores)) {
         foreach ($this->stores as $storeId) {
             $manufacturer->addToStore($storeId);
         }
     }
 }
开发者ID:damnpoet,项目名称:yiicart,代码行数:21,代码来源:ManufacturerForm.php

示例4: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $filename = $this->argument('filename');
     if (!$this->option('testrun') == 'true') {
         $this->comment('======= Importing ' . $filename . ' =========');
     } else {
         $this->comment('====== TEST ONLY Import for ' . $filename . ' ====');
         $this->comment('============== NO DATA WILL BE WRITTEN ==============');
     }
     if (!ini_get("auto_detect_line_endings")) {
         ini_set("auto_detect_line_endings", '1');
     }
     $csv = Reader::createFromPath($this->argument('filename'));
     $csv->setNewline("\r\n");
     $csv->setOffset(1);
     $duplicates = '';
     // Loop through the records
     $nbInsert = $csv->each(function ($row) use($duplicates) {
         $status_id = 1;
         if (is_numeric($row[0])) {
             $this->comment('User ' . $row[0] . ' is not a name - assume this user already exists');
         } elseif ($row[0] == '') {
             $this->comment('No user data provided - skipping user creation, just adding asset');
         } else {
             // Generate an email based on their name
             $name = explode(" ", $row[0]);
             $first_name = $name[0];
             $last_name = '';
             $email_last_name = '';
             if ($first_name == 'Unknown') {
                 $status_id = 7;
             }
             if (!array_key_exists(1, $name)) {
                 $last_name = '';
                 $email_last_name = $last_name;
                 $email_prefix = $first_name;
             } else {
                 // Loop through the rest of the explode so you don't truncate
                 for ($x = 0; $x < count($name); $x++) {
                     if ($x > 0 && $name[$x] != '') {
                         $last_name .= ' ' . $name[$x];
                         $email_last_name .= $name[$x];
                     }
                 }
                 $email_prefix = $first_name[0] . $email_last_name;
             }
             $email = strtolower(str_replace('.', '', $email_prefix)) . '@' . $this->option('domain');
             $email = str_replace("'", '', $email);
             $this->comment('Full Name: ' . $row[0]);
             $this->comment('First Name: ' . $first_name);
             $this->comment('Last Name: ' . $last_name);
             $this->comment('Email: ' . $email);
             $this->comment('Category Name: ' . $row[1]);
             $this->comment('Item: ' . $row[2]);
             $this->comment('Manufacturer ID: ' . $row[3]);
             $this->comment('Model No: ' . $row[4]);
             $this->comment('Serial No: ' . $row[5]);
             $this->comment('Asset Tag: ' . $row[6]);
             $this->comment('Location: ' . $row[7]);
         }
         $this->comment('------------- Action Summary ----------------');
         if (isset($email)) {
             if ($user = User::where('email', $email)->first()) {
                 $this->comment('User ' . $email . ' already exists');
             } else {
                 // Create the user
                 $user = Sentry::createUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10), 'activated' => true, 'permissions' => array('admin' => 0, 'user' => 1), 'notes' => 'Imported user'));
                 // Find the group using the group id
                 $userGroup = Sentry::findGroupById(3);
                 // Assign the group to the user
                 $user->addGroup($userGroup);
                 $this->comment('User ' . $first_name . ' created');
             }
         } else {
             $user = new User();
         }
         // Check for the location match and create it if it doesn't exist
         if ($location = Location::where('name', $row[7])->first()) {
             $this->comment('Location ' . $row[7] . ' already exists');
         } else {
             $location = new Location();
             $location->name = e($row[7]);
             $location->address = '';
             $location->city = '';
             $location->state = '';
             $location->country = '';
             $location->user_id = 1;
             if (!$this->option('testrun') == 'true') {
                 if ($location->save()) {
                     $this->comment('Location ' . $row[7] . ' was created');
                 } else {
                     $this->comment('Something went wrong! Location ' . $row[1] . ' was NOT created');
                 }
             } else {
                 $this->comment('Location ' . $row[7] . ' was (not) created - test run only');
//.........这里部分代码省略.........
开发者ID:stackedcreative,项目名称:snipe-it,代码行数:101,代码来源:ImportCommand.php

示例5: Manufacturer

            $lead->team_set_id = $lead->team_id;
        }
    }
    $lead->primary_address_postalcode = mt_rand(10000, 99999);
    $lead->primary_address_country = $sugar_demodata['primary_address_country'];
    $lead->save();
    if ($i % 10 === 0) {
        echo '.';
    }
}
foreach ($sugar_demodata['manufacturer_seed_data_names'] as $v) {
    $manufacturer = new Manufacturer();
    $manufacturer->name = $v;
    $manufacturer->status = "Active";
    $manufacturer->list_order = "1";
    $manufacturer->save();
    $manufacturer_id_arr[] = $manufacturer->id;
}
echo '.';
$list_order = 1;
foreach ($sugar_demodata['shipper_seed_data_names'] as $v) {
    $shipper = new Shipper();
    $shipper->name = $v;
    $shipper->status = "Active";
    $shipper->list_order = $list_order;
    $list_order++;
    $shipper->save();
    $ship_id_arr[] = $shipper->id;
}
echo '.';
foreach ($sugar_demodata['productcategory_seed_data_names'] as $v) {
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:31,代码来源:populateSeedData.php

示例6: fire


//.........这里部分代码省略.........
         $this->comment('Purchase Date: ' . $user_asset_purchase_date);
         $this->comment('Purchase Cost: ' . $user_asset_purchase_cost);
         $this->comment('Notes: ' . $user_asset_notes);
         $this->comment('Company Name: ' . $user_asset_company_name);
         $this->comment('------------- Action Summary ----------------');
         if ($user_username != '') {
             if ($user = User::MatchEmailOrUsername($user_username, $user_email)->whereNotNull('username')->first()) {
                 $this->comment('User ' . $user_username . ' already exists');
             } else {
                 // Create the user
                 $user = Sentry::createUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $user_email, 'username' => $user_username, 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 12), 'activated' => true, 'permissions' => array('admin' => 0, 'user' => 1), 'notes' => 'User imported through asset importer'));
                 // Find the group using the group id
                 $userGroup = Sentry::findGroupById(3);
                 // Assign the group to the user
                 $user->addGroup($userGroup);
                 $this->comment('User ' . $first_name . ' created');
             }
         } else {
             $user = new User();
         }
         // Check for the location match and create it if it doesn't exist
         if ($location = Location::where('name', e($user_asset_location))->first()) {
             $this->comment('Location ' . $user_asset_location . ' already exists');
         } else {
             $location = new Location();
             if ($user_asset_location != '') {
                 $location->name = e($user_asset_location);
                 $location->address = '';
                 $location->city = '';
                 $location->state = '';
                 $location->country = '';
                 $location->user_id = 1;
                 if (!$this->option('testrun') == 'true') {
                     if ($location->save()) {
                         $this->comment('Location ' . $user_asset_location . ' was created');
                     } else {
                         $this->comment('Something went wrong! Location ' . $user_asset_location . ' was NOT created');
                     }
                 } else {
                     $this->comment('Location ' . $user_asset_location . ' was (not) created - test run only');
                 }
             } else {
                 $this->comment('No location given, so none created.');
             }
         }
         if (e($user_asset_category) == '') {
             $category_name = 'Unnamed Category';
         } else {
             $category_name = e($user_asset_category);
         }
         // Check for the category match and create it if it doesn't exist
         if ($category = Category::where('name', e($category_name))->where('category_type', 'asset')->first()) {
             $this->comment('Category ' . $category_name . ' already exists');
         } else {
             $category = new Category();
             $category->name = e($category_name);
             $category->category_type = 'asset';
             $category->user_id = 1;
             if ($category->save()) {
                 $this->comment('Category ' . $user_asset_category . ' was created');
             } else {
                 $this->comment('Something went wrong! Category ' . $user_asset_category . ' was NOT created');
             }
         }
         // Check for the manufacturer match and create it if it doesn't exist
         if ($manufacturer = Manufacturer::where('name', e($user_asset_mfgr))->first()) {
开发者ID:cralle,项目名称:snipe-it,代码行数:67,代码来源:AssetImportCommand.php

示例7: fire


//.........这里部分代码省略.........
         $this->comment('Serial No: ' . $user_asset_serial);
         $this->comment('Asset Tag: ' . $user_asset_tag);
         $this->comment('Location: ' . $user_asset_location);
         $this->comment('Purchase Date: ' . $user_asset_purchase_date);
         $this->comment('Notes: ' . $user_asset_notes);
         $this->comment('------------- Action Summary ----------------');
         if ($user_email != '') {
             if ($user = User::where('email', $user_email)->first()) {
                 $this->comment('User ' . $user_email . ' already exists');
             } else {
                 // Create the user
                 $user = Sentry::createUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $user_email, 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10), 'activated' => true, 'permissions' => array('admin' => 0, 'user' => 1), 'notes' => 'Imported user'));
                 // Find the group using the group id
                 $userGroup = Sentry::findGroupById(3);
                 // Assign the group to the user
                 $user->addGroup($userGroup);
                 $this->comment('User ' . $first_name . ' created');
             }
         } else {
             $user = new User();
         }
         // Check for the location match and create it if it doesn't exist
         if ($location = Location::where('name', $user_asset_location)->first()) {
             $this->comment('Location ' . $user_asset_location . ' already exists');
         } else {
             $location = new Location();
             $location->name = e($user_asset_location);
             $location->address = '';
             $location->city = '';
             $location->state = '';
             $location->country = '';
             $location->user_id = 1;
             if (!$this->option('testrun') == 'true') {
                 if ($location->save()) {
                     $this->comment('Location ' . $user_asset_location . ' was created');
                 } else {
                     $this->comment('Something went wrong! Location ' . $user_asset_location . ' was NOT created');
                 }
             } else {
                 $this->comment('Location ' . $user_asset_location . ' was (not) created - test run only');
             }
         }
         // Check for the category match and create it if it doesn't exist
         if ($category = Category::where('name', $user_asset_category)->where('category_type', 'asset')->first()) {
             $this->comment('Category ' . $user_asset_category . ' already exists');
         } else {
             $category = new Category();
             $category->name = e($user_asset_category);
             $category->category_type = 'asset';
             $category->user_id = 1;
             if ($category->save()) {
                 $this->comment('Category ' . $user_asset_category . ' was created');
             } else {
                 $this->comment('Something went wrong! Category ' . $user_asset_category . ' was NOT created');
             }
         }
         // Check for the manufacturer match and create it if it doesn't exist
         if ($manufacturer = Manufacturer::where('name', $user_asset_mfgr)->first()) {
             $this->comment('Manufacturer ' . $user_asset_mfgr . ' already exists');
         } else {
             $manufacturer = new Manufacturer();
             $manufacturer->name = e($user_asset_mfgr);
             $manufacturer->user_id = 1;
             if ($manufacturer->save()) {
                 $this->comment('Manufacturer ' . $user_asset_mfgr . ' was created');
             } else {
开发者ID:norganna,项目名称:snipe-it,代码行数:67,代码来源:ImportCommand.php


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