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


PHP product::save方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //dd($request);
     $product = new product();
     $product->name = $request->name;
     $product->price = $request->price;
     $product->save();
     return redirect()->route('product.index');
 }
开发者ID:SigurdMW,项目名称:learning-laravel-5,代码行数:15,代码来源:ProductController.php

示例2: createProduct

 public function createProduct()
 {
     $product = new product();
     $product->product_name = Input::get('product_name');
     $product->categories = Input::get('categories');
     $product->suppliers = Input::get('suppliers');
     $product->cost_price = Input::get('cost_price');
     $product->unit_price = Input::get('unit_price');
     $product->quantity = Input::get('quantity');
     $product->reorder_level = Input::get('reorder_level');
     $product->location = Input::get('location');
     $product->description = Input::get('description');
     $product->save();
     return View::make('product.index');
 }
开发者ID:nangei,项目名称:wpa8pos,代码行数:15,代码来源:ProductController.php

示例3: user

    exit;
}
$expected = '{"customerId":2,"userId":{"id":4,"login":"testuser","active":0,"customerId":0,"firstName":"john","lastName":"Doe Jr","password":"","createdAt":"' . $client->createdAt . '","updatedAt":null,"expires":null,"loginCount":0},"productName":"product6","id":6}';
if ($obj->with('userId')->toJson() != $expected) {
    echo "Multisave problem\n";
    echo $obj->with('userId')->toJson();
    exit;
}
$u = new user();
$u->active = 'test';
$u->customerId = 'test';
$u->expires = 'test;';
$u->firstName = 'test';
$obj = new product();
$obj->userId = $u;
$obj->save();
if ($obj->save()) {
    echo "validation 1 failed\n";
    exit;
}
if (count($obj->errors) != 7) {
    print_r($obj->errors);
    echo "validation 2 failed\n";
    exit;
}
if (!user::byId(1) instanceof user) {
    echo "wrong return type1";
}
if (!is_array(user::ArrayBuilder()->byId(1))) {
    echo "wrong return type2";
}
开发者ID:TwistItLabs,项目名称:website,代码行数:31,代码来源:dbObjectTests.php

示例4: addAccessories

 function addAccessories($productId)
 {
     $product = new product($productId);
     $arr = $this->input->post('productCheck');
     if ($arr != "") {
         foreach ($arr as $row) {
             $accessory = new Product($row);
             $product->save(array('accessories' => $accessory));
             $accessory->clear();
         }
     }
 }
开发者ID:lxthien,项目名称:batdongsan,代码行数:12,代码来源:products.php

示例5: tf

$tf = new tf();
$tflist = $tf->get_assoc_array("tfID", "tfName");
$extra_options = array("-1" => "META: Project TF", "-2" => "META: Salesperson TF", config::get_config_item("mainTfID") => "Main Finance TF (" . tf::get_name(config::get_config_item("mainTfID")) . ")", config::get_config_item("outTfID") => "Outgoing Funds TF (" . tf::get_name(config::get_config_item("outTfID")) . ")", config::get_config_item("inTfID") => "Incoming Funds TF (" . tf::get_name(config::get_config_item("inTfID")) . ")");
// Prepend the META options to the tflist.
$tflist = $extra_options + $tflist;
$TPL["companyTF"] = $tflist[config::get_config_item("mainTfID")];
$TPL["taxTF"] = $tflist[config::get_config_item("taxTfID")];
$taxRate = config::get_config_item("taxPercent") / 100.0;
$TPL["taxRate"] = $taxRate;
if ($_POST["save"]) {
    $product->read_globals();
    $product->set_value("productActive", isset($_POST["productActive"]) ? 1 : 0);
    !$product->get_value("productName") and alloc_error("Please enter a Product Name.");
    !$product->get_value("sellPrice") and alloc_error("Please enter a Sell Price.");
    if (!$TPL["message"]) {
        $product->save();
        $productID = $product->get_id();
        // If they were in the middle of creating a sale, return them back there
        if ($_REQUEST["productSaleID"]) {
            alloc_redirect($TPL["url_alloc_productSale"] . "productSaleID=" . $_REQUEST["productSaleID"]);
        } else {
            alloc_redirect($TPL["url_alloc_product"] . "productID=" . $productID);
        }
    }
    $product->set_values();
} else {
    if ($_POST["delete"]) {
        $product->read_globals();
        $product->delete();
        alloc_redirect($TPL["url_alloc_productList"]);
    }
开发者ID:cjbayliss,项目名称:alloc,代码行数:31,代码来源:product.php

示例6: importProduct


//.........这里部分代码省略.........
             $errorSet[$count] = "No product name (title) supplied, skipping this record...";
             continue;
         }
         $product->parent_id = $data[1];
         $product->child_rank = $data[2];
         $product->title = stripslashes(stripslashes($data[3]));
         $product->body = utf8_encode(stripslashes(reportController::parseAndTrimImport($data[4], true)));
         //$product->body = utf8_encode(stripslashes(stripslashes(($data[4]))));
         $product->model = stripslashes(stripslashes($data[5]));
         $product->warehouse_location = stripslashes(stripslashes($data[6]));
         $product->sef_url = stripslashes(stripslashes($data[7]));
         $product->meta_title = stripslashes(stripslashes($data[8]));
         $product->meta_keywords = stripslashes(stripslashes($data[9]));
         $product->meta_description = stripslashes(stripslashes($data[10]));
         $product->tax_class_id = $data[11];
         $product->quantity = $data[12];
         $product->availability_type = $data[13];
         $product->base_price = $data[14];
         $product->special_price = $data[15];
         $product->use_special_price = $data[16];
         $product->active_type = $data[17];
         $product->product_status_id = $data[18];
         $product->surcharge = $data[31];
         $product->feed_title = stripslashes(stripslashes($data[33]));
         $product->feed_body = stripslashes(stripslashes($data[34]));
         if (empty($product->id)) {
             $product->minimum_order_quantity = 1;
         }
         if ($product->parent_id == 0) {
             $createCats = array();
             $createCatsRank = array();
             for ($x = 19; $x <= 30; $x++) {
                 if (!empty($data[$x])) {
                     $result = $this->parseCategory($data[$x]);
                 } else {
                     continue;
                 }
                 if (is_numeric($result)) {
                     $createCats[] = $result;
                     $createCatsRank[$result] = $data[32];
                 } else {
                     $errorSet[$count][] = $result;
                     continue 2;
                 }
             }
         }
         /*[0] => id
           [1] => parent_id
           [2] => child_rank
           [3] => title
           [4] => model
           [5] => warehouse_location
           [6] => sef_url
           [7] => meta_title
           [8] => meta_keywords
           [9] => meta_description
           [10] => base_price
           [11] => special_price
           [12] => use_special_price
           [13] => active_type
           [14] => product_status_id
           [15] => category1
           [16] => category2
           [17] => category3
           [18] => category4
           [19] => surcharge*/
         //eDebug($createCats,true);
         if (!empty($product->user_input_fields) && is_array($product->user_input_fields)) {
             $product->user_input_fields = serialize($product->user_input_fields);
         }
         //eDebug($product->user_input_fields);
         if (!empty($product->user_input_fields) && !is_array($product->user_input_fields)) {
             $product->user_input_fields = str_replace("'", "\\'", $product->user_input_fields);
         }
         //eDebug($product->user_input_fields,true);
         $product->save(false);
         //eDebug($product->body);
         //sort order and categories
         if ($product->parent_id == 0) {
             $product->saveCategories($createCats, $createCatsRank);
             //eDebug($createCatsRank);
         }
         echo "Sucessfully imported row " . $count . ", product: " . $product->title . "<br/>";
         //eDebug($product);
     }
     if (count($errorSet)) {
         echo "<br/><hr><br/><font color='red'>The following records were NOT imported:<br/>";
         foreach ($errorSet as $row => $err) {
             echo "Row: " . $row . ". Reason:<br/>";
             if (is_array($err)) {
                 foreach ($err as $e) {
                     echo "--" . $e . "<br/>";
                 }
             } else {
                 echo "--" . $err . "<br/>";
             }
         }
         echo "</font>";
     }
 }
开发者ID:notzen,项目名称:exponent-cms,代码行数:101,代码来源:importexportController.php


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