/**
  * @return \Illuminate\Http\JsonResponse
  */
 public function products()
 {
     $distributors = Distributor::all();
     $products = Product::orderBy('name')->get();
     $product_count = 0;
     foreach ($products as $product) {
         $dist_name = Distributor::where('id', '=', $product->distributor_id);
         if ($dist_name->count()) {
             $dist_name = $dist_name->first()->name;
             $products[$product_count]->distributor_name = $dist_name;
         }
         $product_count++;
     }
     return response()->json(['distributors' => $distributors, 'products' => $products]);
 }
 public function paginateProduct($page)
 {
     return Product::orderBy('id', 'desc')->paginate($page);
 }
 /**
  * Untuk menampilkan semua data product
  * 
  * @return [type] [description]
  */
 public function index()
 {
     return ['status' => 'success', 'products' => Product::orderBy('id', 'desc')->get()];
 }
Beispiel #4
0
 /**
  * Show the home page to the user.
  *
  * @return Response
  */
 public function index()
 {
     $data['brands'] = Brands::all();
     $data['latest'] = Product::orderBy('product_id', 'desc')->take('6')->get();
     return view('frontend/livesearch', $data);
 }
 public function newProducts()
 {
     $products = Product::orderBy('created_at', 'desc')->limit(10);
     return view('site.pages.popular')->with('products', $products);
 }