當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Photo::whereIn方法代碼示例

本文整理匯總了PHP中app\Photo::whereIn方法的典型用法代碼示例。如果您正苦於以下問題:PHP Photo::whereIn方法的具體用法?PHP Photo::whereIn怎麽用?PHP Photo::whereIn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Photo的用法示例。


在下文中一共展示了Photo::whereIn方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ProductOfCate

 public function ProductOfCate($slug)
 {
     $cate_id = Category::where('slug', '=', $slug)->first();
     $categories = Category::all();
     $productOfcate = Product::where('category_id', $cate_id->id)->orderBy('created_at', 'DESC')->get();
     $featured_products = FeaturedProduct::orderBy('rank', 'ASC')->get();
     foreach ($featured_products as $i) {
         $id[] = $i->product_id;
     }
     $featured_photo = Photo::whereIn('product_id', $id)->get();
     $lastest_product = Product::orderBy('created_at', 'DESC')->limit(8)->get();
     return view('pages.category', compact('productOfcate', 'cate_id', 'categories', 'featured_products', 'featured_photo', 'lastest_product'));
 }
開發者ID:nguyentantintb,項目名稱:wedding-card,代碼行數:13,代碼來源:PagesController.php

示例2: store

 /**
  * Product store
  *
  * @param ShopProductStoreRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(ShopProductStoreRequest $request)
 {
     $product = Product::create($request->only('name', 'content', 'price', 'active'));
     if ($request->has('photos')) {
         $photos = Photo::whereIn('id', $request->get('photos'))->get();
         $product->photos()->saveMany($photos);
     }
     if ($request->has('category_id')) {
         $product->categories()->attach($request->get('category_id'));
     }
     //@Todo check field before save
     $product->fields()->attach(array_keys($request->field));
     foreach ($request->get('field') as $fieldId => $value) {
         if (!empty($value)) {
             $field = Field::findOrFail($fieldId);
             FieldValue::create([$field->type => $value[$field->type], 'product_id' => $product->id, 'field_id' => $field->id]);
         }
     }
     if ($request->has('fields')) {
         $product->fields()->attach($request->get('fields'));
     }
     Session::flash('message', 'Товар добавлен');
     return redirect()->route('manager.shop.product.edit', $product->id);
 }
開發者ID:devillom,項目名稱:simpleshop,代碼行數:30,代碼來源:ShopProductController.php

示例3: update

 /**
  * Update Category
  *
  * @param ShopCategoryUpdateRequest $request
  * @param $category
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(ShopCategoryUpdateRequest $request, Category $category)
 {
     $category->update(['name' => $request->get('name'), 'content' => $request->get('content')]);
     if ($request->has('parent_id')) {
         $parent = Category::find($request->get('parent_id'));
         $parent->children()->save($category);
     } else {
         $category->parent_id = null;
         $category->save();
     }
     if ($request->has('fields')) {
         $category->fields()->sync($request->get('fields'));
     }
     if ($request->has('photos')) {
         $photos = Photo::whereIn('id', $request->get('photos'))->get();
         $category->photos()->saveMany($photos);
     }
     Session::flash('message', 'Категория изменено');
     return redirect()->route('manager.shop.category.index');
 }
開發者ID:devillom,項目名稱:simpleshop,代碼行數:27,代碼來源:ShopCategoryController.php


注:本文中的app\Photo::whereIn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。