Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $pro = new Product();
     $adSlotObj = new Adslot();
     $catObj = new Category();
     $brandObj = new Brand();
     /*getting all products for all slots(currently we have 7 slots)*/
     $adSlot_data = $adSlotObj->with(['products'])->get();
     /*t1-t7*/
     // dd($adSlot_data[4]['products'][0]);
     $category_temp_data = $catObj->orderBy('created_at')->take(10)->get();
     /*f1-f10*/
     $brand_data = $brandObj->with(['products'])->get();
     $category_data = [];
     foreach ($category_temp_data as $cat_id) {
         $cat_latest_product = $pro->where('category_id', '=', $cat_id['id'])->orderBy('created_at')->take(1)->pluck('photo_1');
         $cat_latest_product_id = $pro->where('category_id', '=', $cat_id['id'])->orderBy('created_at')->take(1)->pluck('id');
         $cat_random_product = $pro->where('category_id', '=', $cat_id['id'])->orderBy(DB::raw('RAND()'))->take(6)->get();
         $cat_brands = $pro->with(['brand'])->where('category_id', '=', $cat_id['id'])->take(5)->get();
         $cat_products_random_photos = [];
         foreach ($cat_random_product as $photo) {
             $cat_products_random_photos[] = $photo;
         }
         $category_data[] = ['color' => $cat_id['color'], 'floor' => $cat_id['floor'], 'name' => $cat_id['name'], 'desc' => $cat_id['description'], 'logo' => $cat_id['logo'], 'latest_photo_id' => $cat_latest_product_id, 'latest_photo' => $cat_latest_product, 'random_photos' => $cat_products_random_photos, 'brands' => $cat_brands];
     }
     return view('landing_page', compact(['adSlot_data', 'category_data']));
 }
 /**
  * List all products.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     // pagination
     $session_type = 'product';
     if (!$request->session()->has('order_by')) {
         $request->session()->put($session_type . '.order_by', 'created_at');
     }
     if (!$request->session()->has('order_dir')) {
         $request->session()->put($session_type . '.order_dir', 'desc');
     }
     if ($request->order_by) {
         $request->session()->put($session_type . '.order_by', $request->order_by);
     }
     if ($request->order_dir) {
         $request->session()->put($session_type . '.order_dir', $request->order_dir);
     }
     $limit = $request->session()->get('limit');
     $orderby = $request->session()->get($session_type . '.order_by') == 'created_at' ? $request->session()->get($session_type . '.order_by') : $request->session()->get('language') . '.' . $request->session()->get($session_type . '.order_by');
     // query products with conditional search
     $products = Product::where('shop_id', $request->session()->get('shop'))->where(function ($query) use($request) {
         if ($request->search) {
             return $query->where('en.name', 'LIKE', '%' . $request->search . '%');
         }
     })->orderBy($orderby, $request->session()->get($session_type . '.order_dir'))->paginate($limit);
     $products->search = $request->search;
     return view('admin/products/index', ['products' => $products]);
 }
Example #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id, $itemId)
 {
     $product = Product::where('id', '=', $id)->where('user_id', '=', Auth::user()->id)->first();
     $order->items()->delete($itemId);
     $this->recalculateDelivery($order);
     return $this->orderToJson($order);
 }
 /**
  * Change the currency.
  *
  * @return Redirect
  */
 public function show(Request $request, string $currency)
 {
     $request->session()->put('currency', $currency);
     $currency = Currency::where('currency', $currency)->first()->toArray();
     $request->session()->put('currency_rate', $currency['rate']);
     // we need to update the basket
     $basket = $request->session()->get('basket');
     foreach ($basket['items'] as $id => $item) {
         if (isset($item['parent_sku'])) {
             // its an option
             $product = Product::where('sku', $item['parent_sku'])->first();
             $price = isset($product->salePrice) && !empty($product->salePrice) ? $product->salePrice : $product->price;
             foreach ($product->option_values as $option) {
                 if ($option['sku'] == $id) {
                     $price = number_format($option['price'] * $request->session()->get('currency_rate'), 2, '.', '');
                 }
             }
         } else {
             $product = Product::find($id);
             $price = isset($product->salePrice) && !empty($product->salePrice) ? $product->salePrice : $product->price;
         }
         $basket['items'][$id]['price'] = $price;
     }
     $request->session()->put('basket', $basket);
     return redirect()->back();
 }
 /**
  * Show Product.
  *
  * @return Response
  */
 public function show($slug)
 {
     $product = Product::where('slug', $slug)->first();
     $file_size = key(array_reverse(config('image.image_sizes')));
     //smallest
     $product->files = $this->getFiles('images/products/' . $product->id . '/' . $file_size);
     return view('themes/basic/products/show', ['product' => $product]);
 }
Example #6
0
 public function getFilterCategory($id)
 {
     $categories = [0 => 'Все'];
     foreach (Category::all() as $category) {
         $categories[$category->id] = $category->name;
     }
     return view('admin.products.index', ['products' => Product::where('category_id', '=', $id)->paginate(15), 'categories' => Category::tree()]);
 }
Example #7
0
 public function showProductsByCat($id)
 {
     if (is_null($id) || empty($id)) {
         die('Некорректный идентификатор категории');
     }
     $products = Product::where('catid', $id)->get();
     return view('products.default', ['products' => $products]);
 }
 /**
  * Adds product to cart
  *
  * @param AddToCartRequest $request
  */
 public function add(AddToCartRequest $request)
 {
     $product = Product::where('active', 1)->findOrFail((int) $request->product_id);
     if ($product) {
         Cart::associate('App\\Models\\Product')->add($product->id, $product->name, 1, $product->price);
     }
     return back();
 }
Example #9
0
 public function ajaxSearch(Request $request, $keyword)
 {
     if ($request->ajax() && $request->isMethod('GET') && trim($keyword) !== '') {
         $stores = Store::where('name', 'LIKE', "%{$keyword}%")->take(10)->get(['slug', 'name']);
         $products = Product::where('name', 'LIKE', "%{$keyword}%")->take(10)->get(['id', 'name']);
         $users = User::where('first_name', 'LIKE', "%{$keyword}%")->orWhere('last_name', 'LIKE', "%{$keyword}%")->orWhere('user_name', 'LIKE', "%{$keyword}%")->take(10)->get(['user_name', 'first_name', 'last_name']);
         return pong(1, ['data' => ['stores' => $stores, 'products' => $products, 'users' => $users]]);
     }
 }
Example #10
0
 public function getSearch()
 {
     $term = Input::get('search_query');
     if ($term != '') {
         $products = Product::where('availability', 1)->where('name', 'like', "%{$term}%")->orWhere('article', 'like', "%{$term}%")->get();
         return view('products.index', ['products' => $products]);
     } else {
         return Redirect::route('home');
     }
 }
 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function show(Request $request)
 {
     $stats['categories'] = Category::where('shop_id', '=', $request->session()->get('shop'))->count();
     $stats['products'] = Product::where('shop_id', '=', $request->session()->get('shop'))->count();
     $stats['customers'] = User::where('shop_id', '=', $request->session()->get('shop'))->count();
     $stats['pages'] = Page::where('shop_id', '=', $request->session()->get('shop'))->count();
     $stats['blogs'] = Blog::where('shop_id', '=', $request->session()->get('shop'))->count();
     $stats['orders'] = Order::where('shop_id', '=', $request->session()->get('shop'))->count();
     $stats['revenue'] = Order::where('shop_id', '=', $request->session()->get('shop'))->sum('total');
     return view('admin/dashboard', ['stats' => $stats]);
 }
Example #12
0
 public function action_clear()
 {
     $products = \App\Models\Product::where('catalog_id', '=', 2)->get();
     $this->output->progressStart(count($products));
     foreach ($products as $product) {
         $this->info($product->id);
         $product->images()->delete();
         $product->delete();
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
 }
 public function delete()
 {
     $id = Input::get('id');
     $getcount = Product::where("attr_set", "=", $id)->count();
     if ($getcount <= 0) {
         AttributeSet::find($id)->attributes()->detach();
         AttributeSet::find($id)->delete();
         return redirect()->back()->with('message', 'Attribute Set deleted successfully!');
     } else {
         return redirect()->back()->with('message', 'Sorry This Attribute Set is Part of a Product! Delete the Product First!');
     }
 }
 /**
  * @param $dist_id
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function deleteDistributor($dist_id)
 {
     $dist = Distributor::where('id', $dist_id);
     $products = Product::where('distributor_id', '=', $dist_id);
     if ($products->count()) {
         return response()->json(['deleted' => false, 'products' => true]);
     } else {
         if ($dist->delete()) {
             return response()->json(['deleted' => true, 'products' => false]);
         }
         return response()->json(['deleted' => false]);
     }
 }
 public function destroy($id)
 {
     $supplier = Supplier::find($id);
     if ($supplier) {
         $deleteProduct = Product::where('supplier_id', '=', $id)->delete();
         if ($supplier->delete()) {
             return ['status' => 'success', 'message' => 'Supplier data successfully deleted.'];
         } else {
             return ['status' => 'failed', 'message' => 'Supplier data failed to deleted.'];
         }
     } else {
         return ['status' => 'failed', 'message' => 'Supplier data not found.'];
     }
 }
Example #16
0
 public static function sendMail($subject, $message, $user_id, $productid)
 {
     $user = User::where('id', $user_id)->first();
     $from_cc = $user->email;
     $owner = Product::where('id', $productid)->first();
     $owner_info = User::where('id', $owner->user_id)->first();
     $sendto = $owner_info->email;
     $data = array('bodytext' => $message);
     Mail::send('email.interest', $data, function ($m) use($user, $subject) {
         $m->from('*****@*****.**', "{$user->first_name} {$user->last_name}");
         $m->subject("{$subject}");
         $m->to("*****@*****.**")->cc("*****@*****.**");
     });
     return 1;
 }
Example #17
0
 public function getFilterdProducts()
 {
     $cats = json_decode(Input::get('filters'), true);
     $products = Product::where("is_individual", 1)->with("savedlist");
     foreach ($cats as $cat) {
         $products->whereHas('categories', function ($query) use($cat) {
             $cats = [];
             foreach ($cat as $cc) {
                 $c = Category::find($cc)->getDescendantsAndSelf();
                 foreach ($c as $ccc) {
                     array_push($cats, $ccc->id);
                 }
             }
             $query = $query->whereIn('cat_id', $cats);
             return $query;
         });
     }
     if (!empty(Input::get('sTerm'))) {
         $products = $products->where("product", "like", "%" . Input::get('sTerm') . "%");
     }
     if (!empty(Input::get('w'))) {
         $products = $products->where("width_" . Input::get('unit'), "<=", Input::get('w'));
     }
     if (!empty(Input::get('h'))) {
         $products = $products->where("height_" . Input::get('unit'), "<=", Input::get('h'));
     }
     if (!empty(Input::get('b'))) {
         $products = $products->where("breadth_" . Input::get('unit'), "<=", Input::get('b'));
     }
     $products = $products->paginate(Config('constants.frontendPaginateNo'));
     foreach ($products as $prd) {
         $attrs = [];
         foreach ($prd->categories()->where("url_key", "!=", "popular")->get() as $cat) {
             $pcat = $cat->getAncestors()->toArray();
             $attrs[$pcat[0]['category']] = $cat->category;
         }
         $prd->tags = $prd->tagged;
         $prd->attrs = $attrs;
         $prd->image = $prd->catalogimgs()->first();
         @($prd->image->filename = asset(Config('constants.productImgPath') . @$prd->image->filename));
         if (User::find(Session::get("userId"))->savedlist->contains($prd->id)) {
             $prd->saved = 1;
         } else {
             $prd->saved = 0;
         }
     }
     return response()->json($products);
 }
 public function update(StoreProductRequest $request, $productId)
 {
     $input = $request->all();
     unset($input['picture']);
     $destinationPath = public_path('uploads');
     $fileName = uniqid();
     if ($request->hasFile('picture')) {
         if ($request->file('picture')->isValid()) {
             $request->file('picture')->move($destinationPath, $fileName);
         }
     }
     $input['picture'] = url('uploads') . '/' . $fileName;
     $input['slug'] = str_replace(' ', '_', strtolower($input['name']));
     $product = Product::where('id', $productId)->update($input);
     return $this->createResponse($product);
 }
Example #19
0
 public function search()
 {
     $searchNeedle = Input::get("search");
     $foundProducts = Product::where('title', 'LIKE', "%{$searchNeedle}%")->get();
     $productIds = [];
     foreach ($foundProducts as $item) {
         $productIds[] = $item->id;
     }
     $pivotResults = DB::table('comp_product')->whereIn("product_id", $productIds)->get();
     $compositionIds = [];
     foreach ($pivotResults as $item) {
         $compositionIds[] = $item->composition_id;
     }
     $foundCompositions = Composition::whereIn("id", $compositionIds)->get();
     $response = ["products" => $foundProducts, "compositions" => $foundCompositions];
     return $response;
 }
Example #20
0
 public static function getActualOffersProducts()
 {
     return \App\Models\ProductInPurchase::paginate(20);
     return \App\Models\Product::where('status', '=', 1)->paginate(20);
     $sql = "select ps.product_id\n            from catalogs ct\n            join products_offers ps on ct.id = ps.catalog_id\n            where ct.status = 1 and ps.status = 1 limit 20";
     $products_ids_obj_arr = \DB::select($sql);
     if (empty($products_ids_obj_arr)) {
         return [];
     }
     $products = [];
     foreach ($products_ids_obj_arr as $product_obj) {
         $products[] = \App\Models\Product::findOrFail($product_obj->product_id);
     }
     //print_r($products); exit;
     return $products;
     $products = \App\Models\Product::where('status', '>', 0)->where('price_1', '>', 0)->paginate(20);
     return $products;
 }
Example #21
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('book', function ($barcode) {
         return Product::where('barcode', $barcode)->firstOrFail();
     });
     $router->bind('unpublished', function ($barcode) {
         $product = Product::with(['organizations' => function ($query) {
             $query->find(Auth::user()->organization->id);
         }, 'is'])->where('barcode', $barcode)->firstOrFail();
         if ($product->organizations->first()->pivot->published == 0) {
             return $product;
         }
         return false;
     });
     $router->bind('user', function ($hash) {
         return User::where('hash', $hash)->first();
     });
 }
Example #22
0
 public function search(Request $request)
 {
     $page = new \stdClass();
     $page->title = 'Поиск';
     $page->keywords = 'Поиск';
     $page->description = 'Поиск';
     $page->key = 'search';
     $menuHtml = $this->menuHtml('cart');
     $menuItems = Menu::all();
     $bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render();
     $categories = Category::orderBy('sort', 'asc')->get();
     $smallCart = $this->smallCart();
     if ($request->has('val')) {
         $products = Product::where('name', 'like', "%{$request->val}%")->orWhere('text', 'like', "%{$request->val}%")->get();
         $val = $request->get('val');
     } else {
         $val = '';
         $products = [];
     }
     return view('site.search', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'page' => $page, 'categories' => $categories, 'products' => $products, 'count' => $smallCart['count'], 'sum' => $smallCart['sum'], 'indexFlag' => true, 'search' => $val]);
 }
Example #23
0
 /**
  * Handle the event.
  *
  * @param  ProductWasPurchased  $event
  * @return void
  */
 public function handle(ProductWasPurchased $event)
 {
     //
     if ($event->oreder->status != 2) {
         $product = Product::where('id', $event->oreder->product_id)->first();
         $server = Server::where('id', $product->server_id)->first();
         $command = str_replace(':steam_id', $event->oreder->steam_id, $product->command);
         $command = str_replace(':quantity', $event->oreder->quantity, $command);
         $data = new SourceQuery();
         try {
             $data->Connect($server->ip, $server->port, 3, $server->engine);
             $data->SetRconPassword($server->rcon_password);
             $data->Rcon($command);
             $event->oreder->status = 2;
             $event->oreder->completed_at = Carbon::now();
             $event->oreder->save();
         } catch (\Exception $e) {
             $e->getMessage();
         }
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $files_list = scandir('/var/www/kotik/storage/app/citynature.ru/');
     $links_arr = [];
     foreach ($files_list as $file_name) {
         if (in_array($file_name, ['.', '..'])) {
             continue;
         }
         $file_content = file_get_contents('/var/www/kotik/storage/app/citynature.ru/' . $file_name);
         preg_match('@<li class="active"><span>(.+?)</span></li>@is', $file_content, $cats);
         $cat = '';
         if (count($cats) == 2) {
             $cat = $cats[1];
         }
         foreach ($this->parse($file_name) as $link) {
             $product_model = \App\Models\Product::where('source_url', '=', $link)->first();
             if (!$product_model) {
                 continue;
             }
             $product_model->base_country_name = trim($cat);
             $product_model->save();
         }
         //$links_arr = array_merge($links_arr, $this->parse($file_name));
     }
     return;
     $curl = curl_init();
     curl_setopt_array($curl, [CURLOPT_RETURNTRANSFER => true]);
     foreach ($links_arr as $link) {
         $file_name = '/var/www/kotik/storage/app/citynature_pages/' . md5($link) . '.html';
         if (file_exists($file_name)) {
             continue;
         }
         $url = 'http://www.citynature.ru' . $link;
         curl_setopt($curl, CURLOPT_URL, $url);
         $res = curl_exec($curl);
         file_put_contents($file_name, $res);
         echo ".";
         sleep(rand(1, 3));
     }
 }
Example #25
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index($slug)
 {
     $explodeSlug = explode('-', $slug);
     $brandId = explode('.', end($explodeSlug))[0];
     if (!$brandId) {
         return false;
     }
     $obj = new Product();
     $AllparentID = Provider::where('parent_key', $brandId)->get()->toArray();
     $idPr = [];
     if ($AllparentID) {
         foreach ($AllparentID as $val) {
             array_push($idPr, $val['id']);
         }
         $res = Product::whereIn('provider_id', $idPr)->orderBy('id', 'desc');
     } else {
         $res = Product::where('provider_id', $brandId)->orderBy('id', 'desc');
     }
     $res = $this->paging($res, $this->req, false);
     $brandName = Provider::find($brandId);
     $data = ['title' => 'Nhãn hiệu', 'brand_name' => $brandName->name, 'product' => $res, 'total' => $this->total, 'total_page' => $this->total_page];
     return View::make('user/brand', $data);
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     // Add Category model for route model binding, use slug as id
     $router->bind('category', function ($value) {
         $category = Category::where('slug', $value)->first();
         if ($category == null) {
             abort(404);
         }
         return $category;
     });
     // Add Product model for route model binding, use slug as id
     $router->bind('product', function ($value) {
         $product = Product::where('slug', $value)->first();
         if ($product == null) {
             abort(404);
         }
         return $product;
     });
     // Add Order model for route model binding
     $router->model('order', 'App\\Models\\Order');
     // Add User model for route model binding
     $router->model('user', 'App\\User');
 }
Example #27
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index($slug)
 {
     $explodeSlug = explode('-', $slug);
     $catId = explode('.', end($explodeSlug))[0];
     if (!$catId) {
         return false;
     }
     $catName = Category::find($catId);
     $obj = new Product();
     $AllparentID = Category::where('parent_key', $catId)->get()->toArray();
     $idPr = [];
     $res = [];
     if ($AllparentID) {
         foreach ($AllparentID as $val) {
             array_push($idPr, $val['id']);
         }
         $res = Product::whereIn('category_id', $idPr)->orderBy('id', 'desc');
     } else {
         $res = Product::where('category_id', $catId)->orderBy('id', 'desc');
     }
     $res = $this->paging($res, $this->req, false);
     $data = ['title' => 'Loại sản phẩm', 'cat_name' => $catName->name, 'product' => $res, 'total' => $this->total, 'total_page' => $this->total_page];
     return View::make('user/category', $data);
 }
Example #28
0
 public function updateStock($id, Request $request)
 {
     $product_id = $request->input('product_id');
     $quality = $request->input('quality');
     $quantity = $request->input('quantity');
     $price = $request->input('price');
     $update = Stock::where('id', '=', $id)->update(['product_id' => $product_id, 'quality' => $quality, 'quantity' => $quantity, 'price' => $price]);
     if ($update) {
         $product = Product::where('id', '=', $product_id)->get();
         if ($product->count()) {
             $type = $product->first()->type;
             $prod_id = $product->first()->id;
         }
         return response()->json(['updated' => true, 'type' => $type, 'product_id' => $prod_id]);
     }
     return response()->json(['update' => false]);
 }
Example #29
0
 /**
  * Add Photo Cover to a book instance
  *
  * @param Request $request
  * @param $barcode
  * @return string
  */
 public function addPhotos(Request $request, $barcode)
 {
     $this->validate($request, ['photo' => 'required|mimes:jpg,jpeg,png,bmp']);
     $photo = $this->makePhoto($request->file('photo'), 'cover');
     Product::where('barcode', $barcode)->firstOrFail()->addPhoto($photo);
     return 'done';
 }
 /**
  * Show Product.
  *
  * @return Response
  */
 public function show(Request $request, $slug)
 {
     $product = Product::where('slug', $slug)->first();
     // product options
     if ($product->options) {
         $product->options = Option::whereIn('_id', $product->options)->get();
         if ($product->option_values) {
             $first = $product->option_values;
             $product->first = reset($first);
         }
     }
     // load only available options based on selected
     $available = [];
     if ($product->option_values) {
         foreach ($product->option_values as $option) {
             foreach ($option['options'] as $key => $opt) {
                 $available[$key][$opt] = [];
                 //$this->available($product, $key, $opt) ;
             }
         }
     }
     // product images
     $file_size = key(array_reverse(config('image.image_sizes')));
     //smallest
     $product->files = $this->getFiles('images/products/' . $product->id . '/' . $file_size);
     return view('themes/kudos/products/show', ['product' => $product, 'available' => $available]);
 }