Exemplo n.º 1
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $categories = Category::with('children', 'products')->where('parent_id', '=', 0)->orderBy('did')->get();
     $hotpros_id = Salesstats::groupBy('product_id')->take(16)->get();
     $hotpros_id = $hotpros_id->lists('product_id');
     $hotpros = Product::with('images')->has('images')->has('prices')->wherein('id', $hotpros_id)->take(16)->get();
     $globals = DB::table('globalsettings')->get();
     $dts = DB::table('deliverytimes')->where('active', true)->get();
     foreach ($dts as $dt) {
         $dt->start = Carbon::parse($dt->start)->format('h:ia');
         $dt->stop = Carbon::parse($dt->stop)->format('h:ia');
     }
     $settings = [];
     foreach ($globals as $global) {
         $name = $global->name;
         $value = $global->value;
         $settings[$name] = $value;
     }
     $offers = Offer::with(['categories', 'categories.products' => function ($q) {
         $q->has('images');
     }, 'brands', 'brands.products' => function ($q) {
         $q->has('images');
     }, 'products' => function ($q) {
         $q->has('images');
     }, 'products.images', 'products.prices'])->where('active', true)->where('start', '<=', Carbon::today()->toDateString())->where('end', '>=', Carbon::today()->toDateString())->take(16)->get();
     //dd($offers);
     $feedbacks = Feedback::with('user')->take(8)->get();
     if ($user = Sentinel::check()) {
         $user = User::findorfail($user->id);
         $flashes = Flashtext::where('active', '1')->get();
         $areas = Area::where('deliverable', '1')->get();
         $viewpros_id = Viewstats::where('user_id', $user->id)->take(16)->get();
         //dd($viewpros_id);
         $viewpros_id = $viewpros_id->lists('product_id');
         $viewpros = Product::with('images')->has('images')->has('prices')->wherein('id', $viewpros_id)->take(16)->get();
         $view->with(['user' => $user, 'flashes' => $flashes, 'areas' => $areas, 'hotpros' => $hotpros, 'viewpros' => $viewpros, 'offers' => $offers, 'settings' => $settings, 'dts' => $dts, 'feedbacks' => $feedbacks, 'categories' => $categories]);
     } else {
         $flashes = Flashtext::where('active', '1')->get();
         $areas = Area::where('deliverable', '1')->get();
         $viewpros_id = Viewstats::where('user_id', 0)->take(16)->get();
         $viewpros_id = $viewpros_id->lists('product_id');
         $viewpros = Product::with('images')->has('images')->has('prices')->wherein('id', $viewpros_id)->take(16)->get();
         $view->with(['flashes' => $flashes, 'areas' => $areas, 'hotpros' => $hotpros, 'viewpros' => $viewpros, 'offers' => $offers, 'settings' => $settings, 'dts' => $dts, 'feedbacks' => $feedbacks, 'categories' => $categories]);
     }
 }
Exemplo n.º 2
0
 public function paymentmode(Request $request)
 {
     //get details from cart not from checkout
     // rewrite this controller
     //$checkout = Checkout::with('orders')->findorfail($checkout_id);
     $user = Sentinel::check();
     $user = User::findorfail($user->id);
     $cart = Cart::content();
     $noofitems = Cart::count();
     $total = Cart::total();
     if ($request->session()->has('tmp_address')) {
         $address = $request->session()->get('tmp_address');
     } else {
         $address = $user->address;
     }
     // foreach($cart as $row)
     // {
     //     $tempcart = Tempcart::create([
     //                    'user_id' => $user->id,
     //                    'product_id' => $row->id,
     //                    'pqty_id' => $row->options->pid,
     //                    'nos' => 1
     //                ]);
     // }
     $flashes = Flashtext::where('active', '1')->get();
     $areas = Area::where('deliverable', '1')->get();
     if ($total < 250) {
         if ($area_id = $user->area_id) {
             $delivery_cost = $areas->find($area_id)->delivery_cost;
         } elseif ($area_id = $request->session()->get('deli_area')) {
             $delivery_cost = $areas->find($area_id)->delivery_cost;
         } else {
             $delivery_cost = "unknown";
         }
     } else {
         $delivery_cost = "0";
     }
     return view('site.paymentmode', compact('user', 'cart', 'noofitems', 'total', 'address', 'flashes', 'areas', 'delivery_cost'));
 }
Exemplo n.º 3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     Flashtext::destroy($id);
     return redirect()->route('admin.flashtext.index');
 }
Exemplo n.º 4
0
 public function login(Request $request)
 {
     if (!Sentinel::check()) {
         $flashes = Flashtext::where('active', '1')->get();
         $areas = Area::where('deliverable', '1')->get();
         if ($redirect = $request->get('redirect')) {
             $request->session()->put('redirect', $redirect);
         }
         //dd($request->session()->get('redirect'));
         return view('site/login', compact('flashtext', 'areas'));
     }
     return back();
 }