/**
  * Show all products by category id.
  *
  * @param $id
  * @return \Illuminate\View\View
  */
 public function category($id)
 {
     $categories = $this->category->orderBy('name')->get();
     $products = $this->product->where('category_id', '=', $id)->paginate(8);
     $categoryName = $this->category->find($id)->name;
     return view('ecomm.shop.partial.products-category', compact('categories', 'products', 'categoryName'));
 }
Exemple #2
0
 public function home()
 {
     //$data['forsidumyndir'] = \App\Page::where('slug', '_forsidumyndir')->first()->getSubs();
     $cats = \App\Category::where('status', 1)->get();
     $prods = \App\Product::where('status', 1)->get();
     $items = [$cats, $prods];
     $kubbar = [];
     foreach ($items as $item) {
         foreach ($item as $v) {
             $frontpaged = trim($v->extras()->get('frontpaged')) ?: 0;
             $size = trim($v->extras()->get('size'));
             $titill = trim($v->extras()->get('titill')) ?: $v->title;
             if ($frontpaged && $frontpaged != 0) {
                 $kubbar[] = ['title' => $titill, 'size' => $size ? $size : 1, 'frontpaged' => $frontpaged, 'fillimage' => $v->fillimage ? true : false, 'path' => $v->fullPath(), 'image' => $v->img()->first(), 'slug' => $v->slug];
             }
         }
     }
     usort($kubbar, function ($a, $b) {
         if ($a['frontpaged'] == $b['frontpaged']) {
             return 0;
         }
         return $a['frontpaged'] < $b['frontpaged'] ? -1 : 1;
     });
     $data['kubbar'] = $kubbar;
     return view('frontend.layout')->with($data);
 }
 public function show($slug)
 {
     // Tökum bara síðasta stykkið
     $e = array_filter(explode("/", $slug));
     $last = end($e);
     $item = \App\Category::where('status', 1)->where('slug', $last)->first();
     if ($item) {
         $cats = \App\Category::where('status', 1)->where('parent_id', $item->id)->orderBy('order')->get();
         $prods = \App\Product::where('status', 1)->where('category_id', $item->id)->orderBy('order')->get();
         $data['items'] = $cats->merge($prods);
         $data['title'] = $item->title;
         return view('frontend.products')->with($data);
     }
     $item = \App\Product::where('status', 1)->where('slug', $last)->first();
     if (!$item) {
         if (!$item) {
             abort(404, 'Fann ekki síðu!');
         }
     }
     $data['item'] = $item;
     $data['siblings'] = $item->getSiblings();
     $data['title'] = isset($item->category->title) ? $item->category->title : 'Vörur';
     if ($item->category_id < 1) {
         $data['title'] = $item->title;
     }
     return view('frontend.product')->with($data);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $order = Order::findOrFail($id);
     $categories = Category::all();
     $products = Product::where('category_id', '=', $categories[0]->id)->get();
     return view('order.show', compact('order', 'categories', 'products'));
 }
 public function show($slug)
 {
     $product = Product::where('slug', $slug)->first();
     //dd($products);
     return view('store.show', compact('product'));
     //Envia los datos a la vista
 }
Exemple #6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $keyword = Input::get('keyword');
     $products = Product::where('nome', '=', '%' . $keyword . '%')->get();
     //        var_dump('search results');
     return redirect()->route('search');
 }
Exemple #7
0
 public function eshopRefer(Request $request)
 {
     if ($request->isMethod('post')) {
         $id = $request->input('id');
         $query = App\Product::where('id', $id)->increment('clicks');
     }
 }
 public static function search($type, $size, $maxPrice, $minPrice, $colors)
 {
     if ($colors == null) {
         $colors = Color::all();
         foreach ($colors as $key => $color) {
             $colors[$key] = $color->id;
         }
     }
     if ($colors != null && $type == null && $size == null) {
         return Product::where('price', '>=', $minPrice)->where('price', '<=', $maxPrice)->whereHas('colors', function ($query) use($colors) {
             $query->whereIn('id', $colors);
         })->get();
     }
     if ($type == null) {
         return Product::where('size', $size)->where('price', '>=', $minPrice)->where('price', '<=', $maxPrice)->whereHas('colors', function ($query) use($colors) {
             $query->whereIn('id', $colors);
         })->get();
     }
     if ($size == null) {
         return Product::where('FK_type', $type)->where('price', '>=', $minPrice)->where('price', '<=', $maxPrice)->whereHas('colors', function ($query) use($colors) {
             $query->whereIn('id', $colors);
         })->get();
     }
     return Product::where('size', $size)->where('FK_type', $type)->where('price', '>=', $minPrice)->where('price', '<=', $maxPrice)->whereHas('colors', function ($query) use($colors) {
         $query->whereIn('id', $colors);
     })->get();
 }
 public function product($productkey)
 {
     $product = Product::where('key', $productkey)->first();
     if ($product != null) {
         // metadata
         $site_title = $product->name . ' - ' . Config::findByKey('site_title')->first()->value;
         SEOMeta::setTitle($site_title);
         SEOMeta::setDescription($product->meta_description);
         SEOMeta::addKeyword([$product->meta_keywords]);
         SEOMeta::addMeta('article:published_time', $product->created_at->toW3CString(), 'property');
         if (isset($product->categories->first()->name)) {
             SEOMeta::addMeta('article:section', $product->categories->first()->name, 'property');
         }
         OpenGraph::setTitle($site_title);
         OpenGraph::setDescription($product->meta_description);
         OpenGraph::setUrl(route('product', ['productkey' => $productkey]));
         OpenGraph::addProperty('type', 'article');
         OpenGraph::addProperty('locale', app()->getLocale());
         OpenGraph::addProperty('locale:alternate', ['vi-vn', 'en-us']);
         OpenGraph::addImage($product->getFirstAttachment());
         OpenGraph::addImage($product->attachments->lists('path'));
         OpenGraph::addImage(['url' => Image::url($product->getFirstAttachment(), 300, 300, array('crop')), 'size' => 300]);
         // end metadata
         return view('frontend.pages.product', compact('product'));
     } else {
         abort(404);
     }
 }
Exemple #10
0
 /**
  *
  */
 public function loadFeed()
 {
     $xml = $this->reader->load($this->feedUrl);
     $content = $xml->getContent();
     $this->content = $xml->getContent();
     foreach ($content as $product) {
         $item = Product::where('externalUrl', '=', $product->productUrl)->first();
         if (!$item) {
             $item = new Product();
         }
         if (strlen($product->brand) > 1) {
             $brand = Brand::where('name', '=', $product->brand)->first();
             if (!$brand) {
                 $brand = new Brand();
                 $brand->name = $product->brand;
                 $brand->save();
             }
             if ($brand->id) {
                 $item->brand = $brand->id;
             }
         }
         $item->name = $product->name;
         $item->description = $product->description;
         $item->price = $product->price;
         $item->regularPrice = $product->regularPrice;
         $item->shippingPrice = $product->shippingPrice;
         $item->externalUrl = $product->productUrl;
         $item->imageUrl = $product->graphicUrl;
         $item->save();
     }
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $my_groups = Customer::where('id', $this->my_customer_id)->first()->groups()->where('active', '1')->get();
     $products = Product::where('active', '1')->get();
     $severities = Severity::orderBy('priority_order')->orderBy('name')->get();
     return view('layouts.ticket.new', ['my_groups' => $my_groups, 'products' => $products, 'severities' => $severities]);
 }
Exemple #12
0
    public function generate($platform, $productID)
    {
        if ($product = Product::where('id', '=', $productID)->first()) {
            $title = $product->name;
            $description = $product->description;
        } else {
            $title = "Title not available";
            $description = "Description not available";
        }
        if ($platform == "facebook") {
            echo '
            
            <title>' . $title . '</title>
            <meta name="description" content="' . $description . '">
<img src="http://media.giphy.com/media/109Ku3hdapZJle/giphy.gif" /> 
            ';
        } else {
            echo '
                
                
            <title>Hmm intresting didnt know about "' . $platform . '" will sure check it out</title>
                
                ';
        }
    }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($id)
 {
     $product = Product::where('id', $id)->get()[0];
     $sliders = Slider::all();
     $categories = Category::all();
     return view('product', compact('sliders', 'categories', 'product'));
 }
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $products = Product::where('quantity', '>', 0)->orderBy('created_at', 'DESC')->limit(10)->get();
     $id = Auth::id();
     $shoppingCart = ShoppingCart::find(md5($id));
     return view('pages.home', compact('products', 'shoppingCart'));
 }
 public function getProductsStatus($id)
 {
     $res = new \StdClass();
     $res->list = new \StdClass();
     $res->list->done_products = round(DB::table('products')->select(DB::raw('sum(unitprice*quantity) as product_sum'))->whereNull('deleted_at')->where('list', '=', $id)->where('status', 'done')->first()->product_sum);
     $res->list->all_products = round(DB::table('products')->select(DB::raw('sum(unitprice*quantity) as product_sum'))->whereNull('deleted_at')->where('list', '=', $id)->first()->product_sum);
     $res->list->budget = round(ShoppingList::find($id)->budget);
     $products = Product::where('list', '=', $id)->get();
     $res->statuses = [];
     $res->product_info = [];
     foreach ($products as $product) {
         $res->statuses[$product->status][] = $product->id;
         $p = new \StdClass();
         $p->id = $product->id;
         $p->name = $product->name;
         $p->unitprice = $product->unitprice;
         $p->quantity = $product->quantity;
         $p->moms = $product->moms;
         $res->product_info[] = $p;
     }
     $res->deleted_products = [];
     foreach (DB::table('products')->where('list', '=', $id)->whereNotNull('deleted_at')->get() as $p) {
         $res->deleted_products[] = $p->id;
     }
     return response()->json($res);
 }
 /**
  * Register a product via barcode and uid (user id)
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function scan()
 {
     header("Access-Control-Allow-Origin: *");
     $response = new YYResponse(FALSE, 'Something went wrong.');
     $validator = Validator::make(Request::all(), ['barcode' => 'required|integer', 'uid' => 'required|integer']);
     if ($validator->fails()) {
         $response->errors = $validator->errors();
         return response()->json($response);
     }
     $product = Product::where(['barcode' => Request::get('barcode')])->get();
     $product = empty($product[0]) ? NULL : $product[0];
     if (empty($product)) {
         $product = new Product();
         $product->barcode = Request::get('barcode');
         $product->uid = Request::get('uid');
         $product->save();
     }
     if (!empty($product)) {
         $response->state = TRUE;
         $response->message = NULL;
         $response->data = $product;
         $response->data->reviews = Product::getReviewsById($product->id);
         $response->data->rating = Product::getRatingById($product->id);
         $response->data->rating->average = $response->data->rating->count > 0 ? $response->data->rating->total / $response->data->rating->count : 0;
         $response->data->review = Product::getReviewsById($product->id, $product->uid);
     }
     return response()->json($response);
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function order()
 {
     $data = Input::all();
     $pay = Pay_method::where('pseudo_name', $data['payment'])->firstOrFail();
     $delivery = Delivery::where('pseudo_name', $data['delivery'])->firstOrFail();
     $order = new Order();
     $order->name = $data['name'];
     $order->telephone = $data['phone'];
     $order->adress = $data['address'];
     $order->email = $data['email'];
     $order->payment_method_id = $pay->id;
     $order->delivery_id = $delivery->id;
     $order->comment = $data['info'];
     $order->status = 'new';
     $order->total_cost = $data['sum'];
     $order->save();
     foreach ($data['cart'] as $name => $value) {
         $prod = Product::where('pseudo_name', $name)->firstOrFail();
         $ord_prod = new OrderProduct();
         $ord_prod->product_id = $prod->id;
         $ord_prod->count = $value;
         $ord_prod->order_id = $order->id;
         $ord_prod->save();
     }
     Mail::send('emails.order_success', ['data' => $data], function ($message) {
         $message->setEncoder(Swift_Encoding::get8BitEncoding());
         $message->to('*****@*****.**', 'John Smith')->subject('New order!');
     });
     return 1;
 }
 public function bag(Request $request, $slug)
 {
     $products = Product::where('slug', $slug)->get();
     $colors = [];
     $sizes = [];
     foreach ($products[0]->color as $color) {
         $colors[] = $color->code;
     }
     foreach ($products[0]->size as $size) {
         $sizes[] = $size->size_name;
     }
     $product = array('id' => $products[0]->id, 'slug' => $products[0]->slug, 'name' => $products[0]->product_name, 'image' => $products[0]->image_name, 'price' => $products[0]->price, 'color' => $colors, 'size' => $sizes, 'qty' => 1);
     if (!session('cart')) {
         $request->session()->put("cart.{$slug}", $product);
     } else {
         if ($request->session()->has("cart.{$slug}")) {
             $a = session('cart')[$slug]['qty'] += 1;
             $request->session()->put("cart.{$slug}.qty", $a);
         } else {
             $request->session()->put("cart.{$slug}", $product);
         }
     }
     $items = $request->session()->get('cart');
     return view('frontend.pages.shopping-bag', compact('items'));
 }
 public function index()
 {
     $cookieCart = json_decode($_COOKIE['cart'], true);
     $cart = [];
     $sum = 0;
     $i = 0;
     foreach ($cookieCart as $cartItem) {
         $cart[] = \App\Product::where('id', $cartItem[0])->first()->toArray();
         $cart[$i]['quantity'] = $cartItem[1];
         if ($cart[$i]['sale'] == 1) {
             $cart[$i]['total'] = $cartItem[1] * $cart[$i]['sale_price'];
         } else {
             $cart[$i]['total'] = $cartItem[1] * $cart[$i]['price'];
         }
         $cart[$i]['color'] = $cartItem[2];
         $cart[$i]['size'] = $cartItem[3];
         $i++;
     }
     foreach ($cart as $num) {
         if ($num['sale'] == 1) {
             $sum += $num['quantity'] * $num['sale_price'];
         } else {
             $sum += $num['quantity'] * $num['price'];
         }
     }
     return view('cart.index', compact('cart', 'sum'));
 }
Exemple #20
0
 public function getSiblings()
 {
     if ($this->category_id > 0) {
         return \App\Product::where('category_id', $this->category_id)->where('id', '!=', $this->id)->get();
     }
     return false;
 }
 /**
  * falta por implementar, no se usa por el momento
  *
  **/
 public function show($id)
 {
     $product = Product::find($id);
     $relatedProducts = Product::where('category', '=', $product->category)->where('id', '!=', $product->id)->take(4)->get();
     //dd($relatedProducts);
     return view('pages.show')->with(['product' => $product, 'relatedProducts' => $relatedProducts]);
 }
Exemple #22
0
 public function single($mr, $currentMonth)
 {
     $actualVisits = [];
     $MonthlyCustomerProducts = [];
     $MRLine = [];
     $doctors = Customer::where('mr_id', $mr)->get();
     foreach ($doctors as $singleDoctor) {
         $actualVisits[$singleDoctor->id] = Report::where('mr_id', $mr)->where('month', $currentMonth)->where('doctor_id', $singleDoctor->id)->count();
         $MonthlyCustomerProducts[$singleDoctor->id] = Customer::monthlyProductsBought([$singleDoctor->id])->toArray();
     }
     $products = Product::where('line_id', Employee::findOrFail($mr)->line_id)->get();
     $coverageStats = Employee::coverageStats($mr, $currentMonth);
     $allManagers = Employee::yourManagers($mr);
     $totalProducts = Employee::monthlyDirectSales($mr, $currentMonth);
     $totalSoldProductsSales = $totalProducts['totalSoldProductsSales'];
     $totalSoldProductsSalesPrice = $totalProducts['totalSoldProductsSalesPrice'];
     $currentMonth = \Carbon\Carbon::parse($currentMonth);
     $lines = MrLines::select('line_id', 'from', 'to')->where('mr_id', $mr)->get();
     foreach ($lines as $line) {
         $lineFrom = \Carbon\Carbon::parse($line->from);
         $lineTo = \Carbon\Carbon::parse($line->to);
         if (!$currentMonth->lte($lineTo) && $currentMonth->gte($lineFrom)) {
             $MRLine = MrLines::where('mr_id', $mr)->where('line_id', $line->line_id)->get();
         }
     }
     $dataView = ['doctors' => $doctors, 'MonthlyCustomerProducts' => $MonthlyCustomerProducts, 'actualVisits' => $actualVisits, 'products' => $products, 'totalVisitsCount' => $coverageStats['totalVisitsCount'], 'actualVisitsCount' => $coverageStats['actualVisitsCount'], 'totalMonthlyCoverage' => $coverageStats['totalMonthlyCoverage'], 'allManagers' => $allManagers, 'totalSoldProductsSales' => $totalSoldProductsSales, 'totalSoldProductsSalesPrice' => $totalSoldProductsSalesPrice, 'MRLines' => $MRLine];
     return view('am.line.single', $dataView);
 }
 /**
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function showAllProducts()
 {
     $categories = Category::with('products')->where('is_active', true)->has('products')->get();
     //$categories = Category::all();
     $products = Product::where('is_active', true)->get();
     return view('frontend.categories.products', compact('products', 'categories'));
 }
Exemple #24
0
 public function search()
 {
     $products = Product::where('line_id', Employee::find(\Auth::user()->id)->line_id)->get();
     $doctors = Customer::where('mr_id', \Auth::user()->id)->get();
     $dataView = ['products' => $products, 'doctors' => $doctors];
     return view('mr.search.sales.search', $dataView);
 }
Exemple #25
0
 /**
  * Save product to database
  */
 public function save()
 {
     $data = ['item_id' => $this->item_id, 'shop_id' => $this->shop_id] + $this->data;
     if (!App\Product::where('shop_id', $this->shop_id)->where('item_id', $this->item_id)->update($this->data) && !App\Product::insert($data)) {
         return false;
     }
     $this->id = App\Product::where('shop_id', $this->shop_id)->where('item_id', $this->item_id)->first()->id;
     if (!$this->id) {
         return false;
     }
     foreach ($this->images as $image) {
         if (!App\Image::where('url', $image['url'])->update($image) && !App\Image::insert($image + ['product_id' => $this->id])) {
             return false;
         }
     }
     /*if( isset( $this->params ) )
     		{
     			foreach( $this->params as $param )
     			{
     				if( !App\Param::where( 'param', $param['param'] )->update( $param ) && 
     					!App\Param::insert( $param + [ 'product_id' => $this->id ] ) )
     					return false;
     			}
     		}*/
     return true;
 }
 public function show($slug)
 {
     // Tökum bara síðasta stykkið
     $e = array_filter(explode("/", $slug));
     $last = end($e);
     $item = \App\Category::where('status', 1)->where('slug', $last)->first();
     if ($item) {
         $cats = \App\Category::where('status', 1)->where('parent_id', $item->id)->orderBy('order')->get();
         $prods = \App\Product::where('status', 1)->where('category_id', $item->id)->orderBy('order')->get();
         $data['items'] = $cats->merge($prods);
         $data['pagetitle'] = $item->title;
         $data['seo'] = $item;
         return view('frontend.products')->with($data);
     }
     $item = \App\Product::where('status', 1)->where('slug', $last)->first();
     if (!$item) {
         if (!$item) {
             abort(404, 'Fann ekki síðu!');
         }
     }
     $data['item'] = $item;
     $data['seo'] = $item;
     $data['images'] = $item->img()->all();
     $data['colors'] = $item->skirt()->all();
     $data['image'] = is_array($data['images']) && array_key_exists(0, $data['images']) ? $data['images'][0] : ['name' => $item->img()->first(), 'title' => ''];
     $data['siblings'] = $item->getSiblings();
     $data['pagetitle'] = isset($item->category->title) ? $item->category->title : 'Vörur';
     if ($item->category_id > 1) {
         $data['pagetitle'] = $item->title;
     }
     return view('frontend.product')->with($data);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $product = \App\Product::where('id', $id)->with('inventories', 'prices')->first();
     if (!$product) {
         return $this->index();
     }
     return view('products.show', compact('product'));
 }
 /**
  * Returns a paginated product index.
  *
  * @param string $q
  * @return Paginator
  */
 public function query($q = null)
 {
     return Product::where(function ($query) use($q) {
         foreach (explode(' ', $q) as $keyword) {
             $query->where('product_number', '=', $q)->orWhere('description', 'like', "%{$keyword}%");
         }
     })->paginate();
 }
Exemple #29
0
 public function search()
 {
     $employeesLines = Employee::select('line_id')->where('manager_id', \Auth::user()->id)->get();
     $products = Product::where('line_id', $employeesLines)->get();
     $MRs = Employee::where('manager_id', \Auth::user()->id)->get();
     $dataView = ['products' => $products, 'MRs' => $MRs];
     return view('am.search.sales.search', $dataView);
 }
Exemple #30
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $products = Product::where('offer', '=', '1')->paginate(9);
     foreach ($products as $product) {
         $product->discountPrice();
     }
     return View::make('home', array('products' => $products));
 }