本文整理汇总了PHP中Attribute::where_attribute_group_id_and_value方法的典型用法代码示例。如果您正苦于以下问题:PHP Attribute::where_attribute_group_id_and_value方法的具体用法?PHP Attribute::where_attribute_group_id_and_value怎么用?PHP Attribute::where_attribute_group_id_and_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attribute
的用法示例。
在下文中一共展示了Attribute::where_attribute_group_id_and_value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post_product_add
public function post_product_add()
{
$data = Input::all();
$sessionArr = array("name" => "", "price" => "", "attrs" => array());
$attributes = array();
//check that product model is exist!
$productCheck = Product::where('model', '=', $data['p_model'])->first();
if (empty($productCheck)) {
//first we fetch the brand and get the ID
if (empty($data['p_brand_other'])) {
$brand = $data['p_brand'];
//e.g $brand = 3;
} else {
//here we get brand ID by brand_other's input if the brand_other is filled
$brandCheck = Brand::where("name", '=', $data['p_brand_other'])->first();
if (empty($brandCheck)) {
$brand = DB::table('brands')->insert_get_id(array('name' => $data['p_brand_other'], 'alias' => Str::slug($data['p_brand_other'])));
} else {
$brand = $brandCheck->id;
}
}
$brandName = Brand::where("id", '=', $brand)->only('name');
$brandalias = Brand::where("id", '=', $brand)->only('alias');
$imageIDs = array();
//pic
$images = $data["userfile"];
$mainImg = $data["active"];
$CategoryfurImages = Category::with('getDescriptions')->where("id", "=", $data['p_category'])->first();
for ($i = 0; $i < sizeof($images['name']); $i++) {
$img = array('name' => $images['name'][$i], 'type' => $images["type"][$i], "tmp_name" => $images["tmp_name"][$i], "error" => $images["error"][$i], "size" => $images["size"][$i]);
try {
array_push($imageIDs, $this->imageSizer($img, $CategoryfurImages));
} catch (Exception $e) {
Session::flash('status', 'Resim eklemede hata oluştu Ürünü tekrar ekleyiniz!\\r\\n' . $e->getMessage());
return Redirect::to('admin/product/new');
}
}
//now insert the product, first things first.
$product = DB::table('products')->insert_get_id(array('brand_id' => $brand, 'model' => $data['p_model'], 'price' => ceil($data['p_price'] / 1.18), 'quantity' => $data['p_qty'], 'tax_class_id' => $data['p_tax'], 'barcode' => $data['p_barcode'], 'alias' => trim(Str::slug($brandalias . ' ' . $data['p_model'])), 'created_at' => DB::raw('NOW()'), 'updated_at' => DB::raw('NOW()')));
//inserting pictures
for ($i = 0; $i < count($imageIDs); $i++) {
$imagesSql = DB::table('product_images')->insert(array('product_id' => $product, 'main' => $mainImg[$i] == 1 ? 1 : 0, 'unique_id' => $imageIDs[$i]));
}
$productDescription = DB::table('product_descriptions')->insert_get_id(array('product_id' => $product, 'name' => $brandName . ' ' . $data['p_model'], 'description' => $data['p_description'], 'variant' => $data['p_variant'], 'tag' => $data['p_tag']));
$sessionArr["name"] = $brandName . ' ' . $data['p_model'];
$sessionArr["price"] = ceil($data['p_price'] / 1.18);
//we insert the product now we set the category where the product belong
$cagetory = DB::table('map_product_category')->insert_get_id(array('product_id' => $product, 'category_id' => $data['p_category']));
$attr_other = $data['attr_other'];
$attrs = array();
$check = true;
foreach ($data['attr'] as $k => $v) {
if (!empty($data['attr_other'][$k])) {
$CheckTheAttr = Attribute::where_attribute_group_id_and_value($k, $attr_other[$k])->first();
if ($CheckTheAttr == null) {
$attrotherID = DB::table('attributes')->insert_get_id(array('attribute_group_id' => $k, 'value' => $data['attr_other'][$k]));
array_push($attributes, "Ekstra eklenen ve girilen ürün özelliği : " . $attr_other[$k]);
$attrs[$k] = $attrotherID;
} else {
$attrs[$k] = $v;
}
} else {
array_push($attributes, "Girilen ürün özelliği : " . $v);
$attrs[$k] = $v;
}
}
array_push($sessionArr["attrs"], $attributes);
$attrsOrdered = array();
foreach ($attrs as $k => $v) {
$attrsOrdered[] = array('product_id' => $product, 'attribute_id' => $v);
}
$attrs = DB::table('map_product_attribute')->insert($attrsOrdered);
} else {
Session::flash('status', 'Bu ürün daha önce sisteme eklenmiş!');
return Redirect::to('admin/product/new');
}
return Redirect::to('admin/product/new')->with("result", $sessionArr);
}