public function index() { $products = Product::all(); $productCode = Product::limit(1)->orderBy('product_code', 'decs')->first(); if (isset($productCode->product_code)) { $crop = substr($productCode->product_code, 4); if ($crop < 9) { $plus = $crop + 1; $urutan = "JOR000" . $plus; } elseif ($crop < 99) { $plus = $crop + 1; $urutan = "JOR00" . $plus; } elseif ($crop < 999) { $plus = $crop + 1; $urutan = "JOR0" . $plus; } elseif ($crop < 9999) { $plus = $crop + 1; $urutan = "JOR" . $plus; } elseif ($crop >= 9999) { $urutan = "ERROR"; } } else { $urutan = "JOR0001"; } // return response()->json(array('data' => $products, 'urutan' => $urutan)); return view('admin.product')->withProducts($products)->withUrutans($urutan); }
public function index() { $data = array('brand' => Brand::all(), 'banner' => Banner::all(), 'product' => Product::limit(9)->offset(0)->get(), 'cart' => Cart::content(), 'total' => Cart::total(), 'download' => Download::limit(3)->offset(0)->get(), 'testimoni' => Testimoni::limit(10)->offset(0)->get()); return view('front.home', compact('data')); }
/** * Show the application welcome screen to the user. * * @return Response */ public function index() { $products = Product::limit(3)->orderBy('created_at', 'asc')->get(); return view('main.welcome', ['products' => $products]); }