/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $data = FeaturedProduct::orderBy('rank', 'asc')->with('product')->get();
     $categories = Category::get();
     $products = Product::get();
     return view('admin.image.featured-product', compact('data', 'categories', 'products'));
 }
Example #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $products = Product::get();
     $users = User::all();
     $cart = Cart::with('cart_items.product.stocks')->first();
     $cartItems = $cart->cart_items;
     return view('checkout.index', compact('products', 'cart', 'cartItems', 'users'));
 }
 public function index()
 {
     $products = Product::get();
     $articles = Blog::orderBy('id', 'DESC')->take(4)->get();
     $galleries = Gallery::orderBy(\DB::raw('RAND()'))->take(5)->get();
     $setting = Setting::first();
     return view('sites.index', compact('products', 'articles', 'galleries', 'setting'));
 }
Example #4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     $users = User::get()->lists('id')->all();
     $products = Product::get()->lists('id')->all();
     foreach (range(1, 30) as $index) {
         Bid::create(['amount' => $faker->randomNumber(), 'user_id' => $faker->randomElement($users), 'product_id' => $faker->randomElement($products)]);
     }
 }
Example #5
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getIndex()
 {
     //
     $categories = array();
     foreach (Category::all() as $category) {
         $categories[$category->id] = $category->name;
     }
     return view('products.index')->with('products', Product::get())->with('categories', $categories);
 }
Example #6
0
 public function run()
 {
     $faker = Faker::create();
     $users = User::get();
     $products = Product::get();
     for ($i = 0; $i < 10; $i++) {
         $user = $users->random(1);
         $status = $faker->randomElement(['open', 'paid', 'pending', 'installed', 'cancelled']);
         $order = Order::create(['user_id' => $user->id, 'status' => $status, 'end_date' => $status == 'installed' || $status == 'cancelled' ? $faker->dateTime() : null]);
         $random = $faker->numberBetween(1, 2);
         for ($y = 0; $y < $random; $y++) {
             $product = $products->random(1);
             OrderDetail::create(['order_id' => $order->id, 'product_id' => $product->id, 'price' => $product->price, 'quantity' => 1]);
         }
     }
 }
 public function run()
 {
     $faker = Faker::create();
     $users = Address::get();
     $status_list = array_keys(trans('globals.order_status'));
     for ($i = 0; $i < 20; $i++) {
         $user = $users->random(1);
         $products = Product::get();
         $type = $faker->randomElement(['cart', 'wishlist', 'order']);
         $status = 'open';
         switch ($type) {
             case 'order':
                 $status = $faker->randomElement($status_list);
                 break;
         }
         $stock = $faker->numberBetween(1, 20);
         $order = Order::create(['user_id' => $user->user_id, 'seller_id' => '3', 'address_id' => $user->id, 'status' => $status, 'type' => $type, 'description' => $type == 'wishlist' ? $faker->companySuffix : '', 'end_date' => $status == 'closed' || $status == 'cancelled' ? $faker->dateTime() : null]);
         $num = $faker->numberBetween(2, 5);
         $list = [];
         if ($num > 1 && count($products) - 1 < $num) {
             $num = count($products) - 1;
         }
         for ($j = 0; $j < $num; $j++) {
             do {
                 $a = true;
                 $product = $products->random(1);
                 if (in_array($product->id, $list)) {
                     $a = false;
                 } else {
                     $list[] = $product->id;
                 }
             } while ($a == false);
             if ($status == 'closed') {
                 $delivery = $faker->dateTime();
             } else {
                 $delivery = $faker->numberBetween(0, 1) ? $faker->dateTime() : null;
             }
             OrderDetail::create(['order_id' => $order->id, 'product_id' => $product->id, 'price' => $product->price, 'quantity' => $stock, 'delivery_date' => $delivery]);
         }
         $order->sendNotice();
     }
 }
	public function anyEntry(Request $request,$id=null)
	{
		if(isset($id) && $id!=null){
			$id_product = $id;
			$product = Product::find($id_product)->toArray();
			session(['current_product' => $product['id']]);
		}else{
			$id_product = session('current_product') !== null ? session('current_product') : 0;
			if($id_product){
				$product = Product::find($id_product)->toArray();
				if(count($product)){
					session(['current_product' => $product['id']]);
				}else{
					$product = Product::get()->last();
					if($product){
						$product= $product->toArray();
						session(['current_product' => $product['id']]);
					}else{
						$product = new Product;
						$product->created_by = \Auth::user()->id;
						$product->save();
						Log::create_log(\Auth::user()->id,'App\Product','Tạo mới sản phẩm số '.$product->id);
						session(['current_product' => $product->id]);
						$product->toArray();
					}
				}
			}else{
				$product = Product::get()->last();
				if($product){
					$product= $product->toArray();
					session(['current_product' => $product['id']]);
				}else{
					$product = new Product;
					$product->created_by = \Auth::user()->id;
					$product->save();
					Log::create_log(\Auth::user()->id,'App\Product','Tạo mới sản phẩm số '.$product->id);
					session(['current_product' => $product->id]);
					$product->toArray();
				}
			}
		}



		//Init array
		$distributes = array();
		$oums = array();
		$producttypes = array();
		$list_instock = array();


		//Get value array
		$distributes = Company::getDistributeList()->get()->toArray();
		$oums = Oum::orderBy('name')->get()->toArray();
		$producttypes = ProductType::get()->toArray();
		if($product['check_in_stock']){
			$list_instock = MProduct::select('m_products.*','product_stocks.in_stock')
						->with('company')->with('oum')
						->where('m_products.product_id','=',session('current_product'))
						->where('module_type','=','in_stock')
						->leftJoin('product_stocks','product_stocks.m_product_id','=','m_products.id')
						->get()->toArray();
		}
		
		$view_list_po = self::getListPo($request);
		$view_list_so = self::getListSo($request);
		$companies = array();
		$companies = Company::orderBy('name')->get()->toArray();
		$arr_create = Product::select('users.name','products.created_at')
					->leftJoin('users','users.id','=','products.created_by')
					->where('products.id','=',$product['id'])
					->get()->first()->toArray();

		$arr_update = Product::select('users.name','products.updated_at')
					->leftJoin('users','users.id','=','products.updated_by')
					->where('products.id','=',$product['id'])
					->get()->first()->toArray();
		$this->layout->arr_create = $arr_create;
		$this->layout->arr_update = $arr_update;
		$list_month =ReceiptMonth::select('month','year')
									->distinct()->where('month','>',0)
									->orderBy('year','DESC')
									->orderBy('month','DESC')
									->get()->toArray();
		
		$this->layout->content=view('product.entry', ['distributes'=>$distributes,
								'oums'=>$oums,
								'producttypes'=>$producttypes,
								'product' => $product,
								'view_list_po'	=> $view_list_po,
								'view_list_so'	=> $view_list_so,
								'list_instock' => $list_instock,
								'companies'	=> $companies,
								'list_month' => $list_month
							        ]);
	}
Example #9
0
 /**
  * Get List of all products.
  *
  * @return Collection
  */
 public function getList()
 {
     $products = $this->product->get();
     return $products;
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $products = Product::get();
     return view('products.index', compact('products'));
 }
 public function index()
 {
     $products = \App\Product::get();
     return response()->json($products);
 }