示例#1
0
 public function getEdit($sid)
 {
     $coupon = Coupon::find($sid);
     if ($coupon == null) {
         $errors = new \Illuminate\Support\MessageBag();
         $errors->add('editError', "The coupon cannot be found because it does not exist or may have been deleted.");
         return redirect('/admin/coupons')->withErrors($errors);
     }
     $categories = $this->getCategories();
     $products = Product::where('active', true)->lists('name', 'id');
     $bundles = Bundle::where('active', true)->lists('name', 'id');
     $membermodules = array();
     $pricelists = Pricelist::join('modules', 'modules.id', '=', 'pricelists.module_id')->join('memberships', 'memberships.id', '=', 'pricelists.membership_id')->orderBy('modules.name')->orderBy('memberships.rank', 'desc')->select('pricelists.*')->get();
     foreach ($pricelists as $pricelist) {
         $membermodules[$pricelist->id] = $pricelist->module->name . " (" . $pricelist->membership->name . ")";
     }
     $product_id = array();
     foreach ($coupon->products as $product) {
         $product_id[$product->id] = $product->id;
     }
     $category_id = array();
     foreach ($coupon->categories as $category) {
         $category_id[$category->id] = $category->id;
     }
     $pricelist_id = array();
     foreach ($coupon->pricelists as $pricelist) {
         $pricelist_id[$pricelist->id] = $pricelist->id;
     }
     $bundle_id = array();
     foreach ($coupon->bundles as $bundle) {
         $bundle_id[$bundle->id] = $bundle->id;
     }
     $data = array('categories' => $categories, 'products' => $products, 'membermodules' => $membermodules, 'bundles' => $bundles, 'coupon' => $coupon, 'product_id' => $product_id, 'category_id' => $category_id, 'pricelist_id' => $pricelist_id, 'bundle_id' => $bundle_id);
     return view('redminportal::coupons/edit', $data);
 }
示例#2
0
 public function getCreate()
 {
     $products = Product::where('active', true)->orderBy('name')->lists('name', 'id');
     $bundles = Bundle::where('active', true)->orderBy('name')->lists('name', 'id');
     $coupons = Coupon::orderBy('code')->lists('code', 'id');
     $pricelists = array();
     $pricelists_get = Pricelist::join('modules', 'modules.id', '=', 'pricelists.module_id')->join('memberships', 'memberships.id', '=', 'pricelists.membership_id')->where('modules.active', true)->orderBy('modules.name')->orderBy('memberships.rank', 'desc')->select('pricelists.*')->get();
     foreach ($pricelists_get as $pricelist) {
         $pricelists[$pricelist->id] = $pricelist->name;
     }
     $payment_statuses = config('redminportal::payment_statuses');
     return view('redminportal::orders/create')->with('products', $products)->with('bundles', $bundles)->with('coupons', $coupons)->with('pricelists', $pricelists)->with('payment_statuses', $payment_statuses);
 }
示例#3
0
 public function getEdit($sid)
 {
     $bundle = Bundle::find($sid);
     if ($bundle == null) {
         $errors = new \Illuminate\Support\MessageBag();
         $errors->add('editError', "The bundle cannot be found because it does not exist or may have been deleted.");
         return redirect('/admin/bundles')->withErrors($errors);
     }
     $categories = Category::where('active', true)->where('category_id', 0)->orWhere('category_id', null)->orderBy('name')->get();
     $products = Product::where('active', true)->lists('name', 'id');
     $membermodules = array();
     $pricelists = Pricelist::join('modules', 'modules.id', '=', 'pricelists.module_id')->join('memberships', 'memberships.id', '=', 'pricelists.membership_id')->where('pricelists.active', true)->orderBy('modules.name')->orderBy('memberships.rank', 'desc')->select('pricelists.*')->get();
     foreach ($pricelists as $pricelist) {
         $membermodules[$pricelist->id] = $pricelist->module->name . " (" . $pricelist->membership->name . ")";
     }
     $product_id = array();
     foreach ($bundle->products as $product) {
         $product_id[$product->id] = $product->id;
     }
     $pricelist_id = array();
     foreach ($bundle->pricelists as $pricelist) {
         $pricelist_id[$pricelist->id] = $pricelist->id;
     }
     $tagString = "";
     foreach ($bundle->tags as $tag) {
         if (!empty($tagString)) {
             $tagString .= ",";
         }
         $tagString .= $tag->name;
     }
     $translated = array();
     foreach ($bundle->translations as $translation) {
         $translated[$translation->lang] = json_decode($translation->content);
     }
     $data = array('categories' => $categories, 'products' => $products, 'membermodules' => $membermodules, 'bundle' => $bundle, 'product_id' => $product_id, 'pricelist_id' => $pricelist_id, 'translated' => $translated, 'categories' => $categories, 'tagString' => $tagString, 'imagine' => new RImage());
     return view('redminportal::bundles/edit', $data);
 }