/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $i = $request->product_id;
     foreach ($i as $key => $product_id) {
         $fp = FeaturedProduct::find($key + 1);
         $fp->product_id = $product_id;
         $fp->save();
     }
     return redirect()->back();
 }
 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'));
 }