Example #1
0
 public static function addProduct($i)
 {
     $item_name = ['Jacket', 'Hoodie', 'Kaos', 'Kemeja', 'Short Pants', 'Long Pants', 'Topi', 'Tas'];
     $color = ['Red', 'Blue', 'Green', 'Tosca', 'Tourquish', 'Orange', 'Lavender', 'Purple', 'Deep Purple', 'Pink', 'White', 'Black'];
     $style = ['Arrival', 'Retro', 'Minimalist', 'Simple', 'Unique', 'Fresh', 'Vintage', 'Stylish', 'Cool', 'Calm'];
     $kataunik = ['Komandan', 'Kopral', 'Sersan', 'Homeless', 'Rocker', 'Freaker', 'Temporary', 'Hancur', 'Baper', 'Kuper', 'Gawl'];
     $deskripsi = ['cocok untuk bepergian ke mana-mana', 'cocok bagi anak muda yang mencari jati diri', 'dipakai untuk segala momen', 'mencerahkan penampilanmu'];
     $harga = ['200000', '250000', '300000', '350000', '400000', '450000', '500000'];
     $gambar = ['jacket_distro.jpg', 'hoodie_distro.jpg', 'kaos_distro.jpg', 'kemeja_distro.jpg', 'short_pants_distro.jpg', 'long_pants_distro.png', 'topi_distro.jpg', 'tas_distro.jpg'];
     $ukuran = ['XS', 'S', 'M', 'L', 'XL', 'XXL'];
     $product = new Product();
     $product->brand_id = Brand::max('id');
     $product->category_id = $i;
     $product->name = $item_name[$i - 1] . ' ' . $color[rand(1, count($color) - 1)] . ' ' . $style[rand(1, count($style) - 1)] . ' ' . $kataunik[rand(1, count($kataunik) - 1)];
     $product->description = $item_name[$i - 1] . ' ' . $color[rand(1, count($color) - 1)] . ' ' . $style[rand(1, count($style) - 1)] . ' ' . $kataunik[rand(1, count($kataunik) - 1)] . ' ' . $deskripsi[rand(1, count($deskripsi) - 1)];
     $product->total_stock = rand(6, 10);
     $product->price_origin = $harga[rand(1, count($harga) - 1)];
     $product->price_discount = $harga[rand(1, count($harga) - 1)];
     $product->discount = '20';
     $product->available_from = '2015-07-01';
     $product->available_to = '2015-07-15';
     $product->save();
     $photo = new Photo();
     $photo->product_id = Product::max('id');
     $photo->caption = $item_name[$i - 1];
     $photo->photo_name = $gambar[$i - 1];
     $photo->photo_url = 'assets/sandbox/' . $gambar[$i - 1];
     $photo->save();
     $size = new Size();
     $size->product_id = Product::max('id');
     $size->name = $ukuran[rand(1, count($ukuran) - 1)];
     $size->stock = rand(1, 3);
     $size->save();
 }
Example #2
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');
     }
 }
 public function filter(Request $request)
 {
     if ($request->input('brand') && $request->input('category') && $request->input('price') != '') {
         $data = Product::with('brands', 'categories', 'photos', 'sizes')->whereBrand_id($request->input('brand'))->whereCategory_id($request->input('category'))->whereBetween('price_discount', explode('-', $request->input('price')))->get();
     } elseif ($request->input('brand') && $request->input('category') != '') {
         $data = Product::with('brands', 'categories', 'photos', 'sizes')->whereBrand_id($request->input('brand'))->whereCategory_id($request->input('category'))->get();
     } elseif ($request->input('brand') && $request->input('price') != '') {
         $data = Product::with('brands', 'categories', 'photos', 'sizes')->whereBrand_id($request->input('brand'))->whereBetween('price_discount', explode('-', $request->input('price')))->get();
     } elseif ($request->input('category') && $request->input('price') != '') {
         $data = Product::with('brands', 'categories', 'photos', 'sizes')->whereCategory_id($request->input('category'))->whereBetween('price_discount', explode('-', $request->input('price')))->get();
     } elseif ($request->input('brand') != '') {
         $data = Product::with('brands', 'categories', 'photos', 'sizes')->whereBrand_id($request->input('brand'))->get();
     } elseif ($request->input('category') != '') {
         $data = Product::with('brands', 'categories', 'photos', 'sizes')->whereCategory_id($request->input('category'))->get();
     } elseif ($request->input('price') != '') {
         $data = Product::with('brands', 'categories', 'photos', 'sizes')->whereBetween('price_discount', explode('-', $request->input('price')))->get();
     } else {
         $data = Product::with('brands', 'categories', 'photos', 'sizes')->get();
     }
     if ($data->count() > 0) {
         return Response::json(['error' => false, 'count' => $data->count(), 'data' => ['products' => $data, 'base_url' => url()]]);
     } else {
         return Response::json(['error' => true, 'message' => 'No data product found']);
     }
 }
Example #4
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));
 }
Example #5
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));
 }
Example #6
0
 function save_product($input)
 {
     $product = new Product();
     // echo Request::file('image');
     $product->name = $input['name'];
     // $product->category = $input['category'];
     // $product->type = $input['type'];
     // $product->age = $input['age'];
     $product->description = $input['description'];
     $product->price = $input['price'];
     $product->price_disc = $input['price_disc'];
     $product->price_reseller = $input['price_reseller'];
     $product->brand = $input['product_brand'];
     $product->code = $input['product_code'];
     $product->created_date = Carbon::now();
     $type = explode(',', $input['type']);
     $age = explode(',', $input['age']);
     $file = Request::file('image');
     $extension = $file->getClientOriginalExtension();
     $destinationPath = './public/upload/';
     $fileName = $input['product_code'] . '.jpg';
     // Request::file('image')->move($destinationPath, $fileName);
     $img = Image::make($file->getRealPath());
     $img->resize(null, 600, function ($constraint) {
         $constraint->aspectRatio();
     })->save($destinationPath . $fileName);
     // $db_type = new Product_type();
     if ($product->save()) {
         $arr_type = [];
         $arr_age = [];
         foreach ($type as $key => $value) {
             array_push($arr_type, ['product_id' => $product->id, 'type' => $value]);
         }
         foreach ($age as $key => $value) {
             array_push($arr_age, ['product_id' => $product->id, 'age' => $value]);
         }
         DB::table('product_type')->insert($arr_type);
         DB::table('product_age')->insert($arr_age);
         return Response::json(array('success' => true, 'pages' => $product->code, 'last_insert_id' => $product->id), 200);
     }
 }
 public function lists($product_id = 0)
 {
     $limit = Request::input('limit', 20);
     $term = Request::input('term');
     $query = Product::select('product_id', 'name', 'status', 'img', 'price', 'description');
     if (!empty($term)) {
         $query->where('name', 'like', DB::raw("'%" . $term . "%'"));
     }
     if (!empty($product_id)) {
         $query->where('product_id', '=', $product_id);
     }
     $products = $query->paginate();
     return response()->json($products);
 }
Example #8
0
 public function confimationProductSold($email_and_content)
 {
     $from_name = 'Covanti';
     $admin_email = Option::where('meta_key', '=', 'admin_email')->first();
     $logo = Option::where('meta_key', '=', 'logo')->first();
     $from = $admin_email->meta_value;
     $subject = 'Konfirmasi Produk Terjual';
     foreach ($email_and_content as $email_seller => $order_details) {
         $to = $email_seller;
         foreach ($order_details as $key => $order_detail) {
             $product = Product::find($order_detail->product_id);
             $order_details[$key]->product_name = $product->name;
         }
         $data = array('order_details' => $order_details, 'logo' => $logo->meta_value);
         $body = view('emails/confirmation_product_sold', $data);
         $this->send($from_name, $from, $to, $subject, $body);
     }
 }
 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');
     }
 }
Example #10
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();
 }
Example #11
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);
 }
Example #12
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id_product
  * @return \Illuminate\Http\Response
  */
 public function destroy($id_product)
 {
     $product = Product::findOrFail($id_product);
     $product_name = $product->name;
     $product->delete();
     return redirect()->route('products.index')->with('message_delete', 'Product ' . $product_name . ' has been successfully deleted');
 }
Example #13
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);
 }
Example #14
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();
 }