Esempio n. 1
0
 public function payment(Request $request)
 {
     $rules = array('no_invoice' => 'required', 'account_name' => 'required', 'bank_account' => 'required', 'bank_name' => 'required', 'admin_account' => 'required', 'total_transfer' => 'required', 'transfer_date' => 'required');
     $validator = Validator::make($request->all(), $rules);
     if (!$validator->fails()) {
         $order = Order::where('no_invoice', $request->no_invoice)->first();
         if (!is_null($order)) {
             $payment = new PaymentConfirmation();
             $payment->no_invoice = $order->no_invoice;
             $payment->account_name = $request->account_name;
             $payment->bank_account = $request->bank_account;
             $payment->bank_name = $request->bank_name;
             $payment->admin_account = $request->admin_account;
             $payment->total_transfer = $request->total_transfer;
             $payment->transfer_date = $request->transfer_date;
             $payment->order_id = $order->id;
             $payment->save();
             $order->order_status = "Telah Dibayar";
             $order->save();
             $orderdetail = OrderDetail::where('order_id', $order->id)->get();
             foreach ($orderdetail as $detail) {
                 $product = Product::where('id', $detail->product_id)->first();
                 $product->sold += $detail->quantity;
                 $product->save();
             }
             return redirect('konfirmasi_pembayaran')->with('success', 'Konfirmasi berhasil .Kami akan mengecek pembayaran Anda');
         } else {
             return redirect('konfirmasi_pembayaran')->with('failed', 'Maaf no invoice tidak terdaftar');
         }
     } else {
         return redirect('konfirmasi_pembayaran')->with('failed', 'Silahkan isi form sesuai yang disediakan');
     }
 }
Esempio n. 2
0
 public function list_product()
 {
     $this->data['css_assets'] = Assets::load('css', ['admin_bootstrap', 'admin_css', 'font-awesome', 'skins', 'dataTables_css']);
     $this->data['js_assets'] = Assets::load('js', ['jquery', 'admin_js', 'admin_bootstrap-js', 'slimscroll', 'fastclick', 'dataTables_js', 'dataTables_bootsjs']);
     $this->data['title'] = 'Product | List';
     $this->data['product'] = Product::where('category_id', 1)->orderBy('created_at', 'DESC')->get();
     $this->data['category'] = Category::get();
     $this->data['distributor'] = Distributor::get();
     return view('admin_layout')->with('data', $this->data)->nest('content', 'admin/product/list_produk', array('data' => $this->data));
 }
Esempio n. 3
0
 public function index()
 {
     $this->data['css_assets'] = Assets::load('css', ['lib-bootstrap', 'style', 'font-awesome', 'font-awesome-min', 'flexslider', 'color-schemes-core', 'color-schemes-turquoise', 'jquery-parallax', 'bootstrap-responsive', 'font-family']);
     $this->data['js_assets'] = Assets::load('js', ['jquery', 'jquery-ui', 'jquery-easing', 'bootstrap-min-lib', 'jquery-isotope', 'jquery-flexslider', 'jquery.elevatezoom', 'jquery-sharrre', 'jquery-gmap3', 'imagesloaded', 'la_boutique', 'jquery-cookie', 'jquery-parallax-lib']);
     $this->data['title'] = 'Home';
     $this->data['category'] = Category::get();
     $this->data['product'] = Product::where('status', 'publish')->orderBy('created_at', 'DESC')->limit(5)->get();
     $this->data['sold'] = Product::where('status', 'publish')->orderBy('sold', 'DESC')->limit(5)->get();
     $this->data['banner'] = Option::where('meta_key', 'banner_home')->first();
     return view('main_layout')->with('data', $this->data)->nest('content', 'home', array('data' => $this->data));
 }
 public function delete($id)
 {
     $products = Product::where('distributor_id', $id)->where('status', 'publish')->get();
     if ($products != '') {
         foreach ($products as $product) {
             $order = OrderDetail::where('product_id', $product->id)->where('review', '')->first();
             if ($order != '') {
                 return redirect('master/distributor/list')->with('error', 'Maaf masih terdapat order dari produk distributor yang belum selesai');
             }
         }
     }
     if ($item != '') {
         return redirect('master/distributor/list')->with('error', 'Maaf masih terdapat produk distributor yang aktif. Silahkan non-aktifkan');
     } else {
         Distributor::find($id)->delete();
         return redirect('master/distributor/list');
     }
 }
Esempio n. 5
0
 public function ask_product(Request $request)
 {
     $user = Sentinel::getUser();
     $product = Product::where('id', $request->product_id)->first();
     $ask = new Ask();
     if ($user->first_name != '') {
         $ask->name = ucwords($user->first_name) . " " . ucwords($user->last_name);
     } else {
         $ask->name = "guest";
     }
     $ask->email = $request->email;
     $ask->type = "pertanyaan";
     $ask->ask = "Produk " . ucwords($product->name) . " - " . $request->message;
     $ask->status = 0;
     $ask->save();
 }
Esempio n. 6
0
 public function sort_search(Request $request)
 {
     if ($request->sortby == 'price' || $request->sortby == 'name') {
         $sort = 'ASC';
     } else {
         $sort = 'DESC';
     }
     if ($request->sortby == 'pricedesc') {
         $request->sortby = 'price';
     }
     if ($request->category_id != '') {
         $this->data['query'] = Product::where('name', 'like', '%' . $request->search . '%')->where('category_id', $request->category_id)->where('status', 'publish')->orderBy($request->sortby, $sort)->Paginate(20);
     } else {
         $this->data['query'] = Product::where('name', 'like', '%' . $request->search . '%')->where('status', 'publish')->orderBy($request->sortby, $sort)->Paginate(20);
     }
     return view('search_content')->with('data', $this->data);
 }
Esempio n. 7
0
 public function get_product_by_status(Request $request)
 {
     $this->data['product'] = Product::where('status', $request->status);
     if ($request->category_id) {
         $this->data['product']->where('category_id', $request->category_id);
     }
     if ($request->subcategory_id) {
         $this->data['product']->where('subcategory_id', $request->subcategory_id);
     }
     $this->data['product'] = $this->data['product']->get();
     return view('admin/product/category_product')->with('data', $this->data);
 }
Esempio n. 8
0
 public function add_review(Request $request)
 {
     $order = Order::where('id', $request->order_id)->first();
     $order->order_status = 'Diterima';
     $order->save();
     $orderdetail = OrderDetail::where('order_id', $request->order_id)->where('product_id', $request->product_id)->get();
     foreach ($orderdetail as $value) {
         $value->review = 'reviewed';
         $value->save();
     }
     $product = Product::where('id', $request->product_id)->first();
     $product->rating += $request->rating;
     $product->save();
     $review = new Reviews();
     $review->user_id = Sentinel::getUser()->id;
     $review->product_id = $product->id;
     $review->rating = $request->rating;
     $review->review = $request->review;
     $review->status = 'publish';
     $review->save();
 }