本文整理汇总了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();
}
示例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)));
}
}
示例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();
}
}
示例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");
示例5: Products
<?php
$product = new Products();
$product->product_types_id = 1;
$product->name = 'Artichoke';
$product->price = 10.5;
$product->active = 'Y';
$product->create();