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


PHP Products::create方法代码示例

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


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

示例1: postCreate

 /**
  *   Handle post data and show our create form
  */
 public function postCreate()
 {
     $error = false;
     Gallery::create(['image' => Input::file('images')]);
     if ($product = Products::create(Input::except('images', '_token'))) {
         return Redirect::to(admin_path('products/edit/' . $product->id));
     }
     View::share('error', 'Couldn’t create your product.');
     return self::getCreate();
 }
开发者ID:BinaryGeometry,项目名称:aviate,代码行数:13,代码来源:ProductsController.php

示例2: run

 public function run()
 {
     $faker = Faker\Factory::create();
     //Products::truncate();
     $suppliers = Suppliers::all()->lists('id');
     $categories = Categories::all()->lists('id');
     for ($i = 0; $i < 20; $i++) {
         $products = Products::create(array('name' => $faker->word, 'quantity' => $faker->numberBetween(1, 900), 'unitPrice' => $faker->randomFloat(5, 1, 5000), 'details' => $faker->text, 'color' => $faker->colorName, 'supplierProductId' => $faker->randomNumber, 'supplierId' => $faker->randomElement($suppliers), 'categoryId' => $faker->randomElement($categories)));
     }
 }
开发者ID:jmrodriguesgoncalves,项目名称:NewTownCabinetry,代码行数:10,代码来源:ProductsTableSeeder.php

示例3: create

 public static function create($data)
 {
     $response = new Response();
     try {
         $data = json_decode($data, true);
         $category = Categories::findFirst($data->categoryId);
         if ($category !== FALSE) {
             /** @var Products $products */
             $product = new Products();
             $product->setAttributes($data);
             $response->data = $product->create();
             $response->status = $response::STATUS_CREATED;
         } else {
             $response->status = $response::STATUS_BAD_REQUEST;
             $response->addError('CATEGORIES_NOT_FOUND');
         }
     } catch (Exception $e) {
         $response->setException($e);
     } finally {
         return $response->toArray();
     }
 }
开发者ID:ynijar,项目名称:products,代码行数:22,代码来源:ProductsService.php

示例4: Products

$products = new Products();
$products->url();
$settings['collection'] = $db->select("collections", "id={$products->collection_id}", 'name,barcodes,variation_ids', 1);
$settings['site'] = $db->select("settings", "id='1'", 'barcodes', 1);
$collection_name = $settings['collection']['name'];
if (isset($_POST['submit'])) {
    if (isset($_GET['move'])) {
        $db->update("products", "collection_id", $_POST['collection_id'], $_GET['move']);
        $html->redirection("products.php?c=" . $_POST['collection_id'] . "&p=" . $_GET['move']);
    } else {
        $products->set_data();
        $error = $products->check_data();
        if (!$error) {
            switch ($_GET['p']) {
                case 'add':
                    $products->create();
                    $html->redirection("products.php?c=" . $_GET['c'] . "&p=add");
                    break;
                default:
                    $products->update();
                    $html->redirection("products.php?c=" . $_GET['c'] . (isset($_GET['f']) ? "&f=" . $_GET['f'] : ''));
                    break;
            }
        }
    }
}
if (isset($_GET['p'])) {
    $products->get_data();
    echo "<div id='page-title' class='row'>";
    echo "<div class='col-xs-12 col-sm-6'>";
    $html->title($_GET['p'] == "add" ? "Add Product" : "{$products->name}", "Collection: {$collection_name}", "left");
开发者ID:HQPDevCrew,项目名称:BPU,代码行数:31,代码来源:products.php

示例5: Products

<?php

$product = new Products();
$product->product_types_id = 1;
$product->name = 'Artichoke';
$product->price = 10.5;
$product->active = 'Y';
$product->create();
开发者ID:aodkrisda,项目名称:phalcon-code,代码行数:8,代码来源:models-1792.php


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