本文整理汇总了PHP中product::create方法的典型用法代码示例。如果您正苦于以下问题:PHP product::create方法的具体用法?PHP product::create怎么用?PHP product::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类product
的用法示例。
在下文中一共展示了product::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
static function install()
{
$db = Database::instance();
$db->query("CREATE TABLE IF NOT EXISTS {products} (\n `id` int(9) NOT NULL auto_increment,\n `name` TEXT NOT NULL,\n `cost` INTEGER(9) default 0,\n `description` varchar(1024),\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;");
product::create("4x6", 5, "4\"x6\" print");
product::create("8x10", 25, "8\"x10\" print");
product::create("8x12", 30, "8\"x12\" print");
module::set_version("basket", 1);
}
示例2: install
static function install()
{
$db = Database::instance();
$db->query("CREATE TABLE IF NOT EXISTS {products} (\n `id` int(9) NOT NULL auto_increment,\n `name` TEXT NOT NULL,\n `cost` DECIMAL(10,2) default 0,\n `description` varchar(1024),\n `postage_band_id` int(9) default 1,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {product_overrides} (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9) NOT NULL,\n `none` BOOLEAN default false,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {item_products} (\n `id` int(9) NOT NULL auto_increment,\n `product_override_id` int(9) NOT NULL,\n `product_id` int(9) NOT NULL,\n `include` BOOLEAN default false,\n `cost` DECIMAL(10,2) default -1,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {postage_bands} (\n `id` int(9) NOT NULL auto_increment,\n `name` TEXT NOT NULL,\n `flat_rate` DECIMAL(10,2) default 0,\n `per_item` DECIMAL(10,2) default 0,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;");
postage_band::create("No Postage", 0, 0);
product::create("4x6", 5, "4\"x6\" print", 1);
product::create("8x10", 25, "8\"x10\" print", 1);
product::create("8x12", 30, "8\"x12\" print", 1);
module::set_version("basket", 2);
}
示例3: store
public function store(Request $request)
{
$this->validate($request, ['name' => 'required|max:50', 'content' => 'required|max:255', 'abstract' => 'required|max:70', 'price' => 'required|numeric', 'category_at' => 'numeric', 'quantity' => 'numeric', 'published_at' => 'required|date_format:d-m-Y', 'status' => 'in:opened,closed', 'thumbnail' => 'image|max:6000']);
$product = product::create($request->all());
$product->tags()->attach($request->input('tags'));
//gestion de l'image dans la page create
if (!is_null($request->file('thumbnail'))) {
$im = $request->file('thumbnail');
$ext = $im->getClientOriginalExtension();
$uri = str_random(12) . '.' . $ext;
$im->move(env('UPLOAD_PATH', './uploads'), $uri);
Picture::create(['uri' => $uri, 'type' => $ext, 'size' => $im->getClientSize(), 'product_id' => $product->id]);
}
return redirect()->intended('product');
}
示例4: add_product
public function add_product()
{
access::verify_csrf();
$form = product::get_add_form_admin();
$valid = $form->validate();
$name = $form->add_product->inputs["name"]->value;
$product = ORM::factory("product")->where("name", "=", $name)->find();
if ($product->loaded()) {
$form->add_product->inputs["name"]->add_error("in_use", 1);
$valid = false;
}
if ($valid) {
$product = product::create($name, $form->add_product->cost->value, $form->add_product->description->value, $form->add_product->postage_band->value);
$product->save();
message::success(t("Created product %product_name", array("product_name" => html::clean($product->name))));
print json_encode(array("result" => "success"));
} else {
print json_encode(array("result" => "error", "form" => $form->__toString()));
}
}
示例5: install
static function install()
{
$db = Database::instance();
$db->query("CREATE TABLE IF NOT EXISTS {products} (\n `id` int(9) NOT NULL auto_increment,\n `name` TEXT NOT NULL,\n `cost` DECIMAL(10,2) default 0,\n `description` varchar(1024),\n `postage_band_id` int(9) default 1,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {product_overrides} (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9) NOT NULL,\n `none` BOOLEAN default false,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {item_products} (\n `id` int(9) NOT NULL auto_increment,\n `product_override_id` int(9) NOT NULL,\n `product_id` int(9) NOT NULL,\n `include` BOOLEAN default false,\n `cost` DECIMAL(10,2) default -1,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {postage_bands} (\n `id` int(9) NOT NULL auto_increment,\n `name` TEXT NOT NULL,\n `flat_rate` DECIMAL(10,2) default 0,\n `per_item` DECIMAL(10,2) default 0,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {orders} (\n `id` int(9) NOT NULL auto_increment,\n `status` int(9) DEFAULT 0,\n `name` varchar(1024),\n `email` varchar(1024),\n `cost` DECIMAL(10,2) default 0,\n `method` int(9) DEFAULT 0,\n `text` TEXT NOT NULL,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS `ipn_messages` (\n `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n `date` int(11) NOT NULL,\n `key` varchar(20) NOT NULL,\n `txn_id` varchar(20) NOT NULL,\n `status` varchar(20) NOT NULL,\n `success` bool default false,\n `text` text,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
postage_band::create("No Postage", 0, 0);
product::create("4x6", 5, "4\"x6\" print", 1);
product::create("8x10", 25, "8\"x10\" print", 1);
product::create("8x12", 30, "8\"x12\" print", 1);
basket::setPaymentDetails("<p>Use the following options to pay for this order.</p>\n<p>Send a chequre to..</p>\n<p>Visit the shop..</p>\n<p>By using internet banking..</p>");
basket::setOrderPrefix("ORDER");
basket::setOrderCompletePage("<p>Your order number is %order_number. To pay for this order please either:</p>\n<p> - Send a cheque for %total_cost to with reference %order_number..</p>\n<p> - Visit the shop and quote the order %order_number..</p>\n<p> - Transfer %total_cost using internet banking with reference %order_number..</p>\n<p>Order will be processed as soon as payment is received. You should receive an e-mail with your order details shortly.</p>");
basket::setOrderCompleteEmail("Hi %name,\n\nThank you for your order the order details are below. To pay for this order please either:\n\n- Send a cheque for %total_cost to with reference %order_number..\n- Visit the shop and quote the order %order_number..\n- Transfer %total_cost using internet banking with reference %order_number..\n\nOrder will be processed as soon as payment is received. For order pick-ups please visit..\n\nOrder Details\n-------------\n%order_details\n\nThanks");
basket::setOrderCompleteEmailSubject("Photography Order %order_number");
module::set_version("basket", 5);
}