Пример #1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $product_size = ProductSize::findOrFail($id);
     $product = Product::findOrFail($product_size->product_id);
     $category = Category::findOrFail($product->category_id);
     $extras = Extra::where('product_size_id', '=', $id)->get();
     return view('product_size.show', compact('product_size', 'product', 'category', 'extras'));
 }
Пример #2
0
 /**
  * Delete an extra
  * @param Request $request
  * @param $id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function destroy(Request $request, $id)
 {
     $event = Event::find($request->input('event'));
     $extra = Extra::find($id);
     if ($extra && $event->user_id == $request->user()->id) {
         $extra->delete();
         //Flash a message to the user
         \Flash::success('Extra deleted');
     } else {
         //Flash a message to the user
         \Flash::danger('Sorry, permission denied');
     }
     //Redirect back to the admin page
     //return redirect(action('EventsController@admin', $request->input('event')));
     return Redirect::back()->with(['tabName' => 'extras']);
 }
Пример #3
0
 public function step2Editor(Product $productsModel, Extra $extraModel)
 {
     $tpl = 0;
     $circulation = CartsCirculation::where('active', '=', 1)->where('alias', '=', 'vizitki')->get();
     $kurs = Config::where('title', '=', 'kurs')->firstOrFail();
     $products = $productsModel->getProd();
     $extra = $extraModel->getExtra();
     $service = Service::where('alias', '=', 'vizitki')->firstOrFail();
     return view('order.template_editor_step2')->with('circulation', $circulation)->with('kurs', $kurs)->with('products', $products)->with('extra', $extra)->with('service', $service)->with('tpl', $tpl);
 }
Пример #4
0
 public function run()
 {
     DB::table('extra')->delete();
     Extra::create(['title' => 'Ламинация лицевой стороны', 'name' => 'laminat1', 'price1' => 1, 'price2' => 2, 'design' => 0, 'active' => 1]);
     Extra::create(['title' => 'Двухстороннее ламинирование', 'name' => 'laminat2', 'price1' => 8, 'price2' => 9, 'design' => 0, 'active' => 1]);
 }
Пример #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Extra::destroy($id);
     return redirect()->back();
 }
Пример #6
0
 /**
  * Formats a messy form and presents the user with a confirmation page (form) before
  * proceeding to payment.
  */
 public function confirmEntry(Request $request)
 {
     // returns a confirm view which then sends the user to the store function above.
     $data = $request->all();
     $user = Auth::user();
     $event = Event::findOrFail($data['event_id']);
     $compSubTotal = 0;
     $extraSubTotal = 0;
     //Format the competitions for display in the confirmation form
     $entries = array();
     //$competitions[$id] = array('detail' => $detail, 'competition' => $competition)
     foreach ($data['competitions'] as $competition_id => $detail_id) {
         if ($detail_id != "noEntry") {
             $competition = Competition::findOrFail($competition_id);
             $detail = Detail::findOrFail($detail_id);
             $entries[$competition_id] = array('competition' => $competition, 'detail' => $detail);
             $compSubTotal += $competition->fee;
         }
     }
     //if for some reason the competitor has forgotten to select a competition, bump them back.
     if (empty($entries)) {
         \Flash::error('You need to select a competition to enter before you can proceed.');
         return redirect(action('EventsController@show', $event->slug));
     }
     //Format the extras for display in the confirmation form
     $extras = array();
     if (key_exists('extras', $data)) {
         foreach ($data['extras'] as $extra_id => $extraOrder) {
             $multiple = 1;
             $infoRequired = NULL;
             if (is_string($extraOrder) == False) {
                 //This is an extra order with an array of info
                 if (array_key_exists('multiple', $extraOrder)) {
                     $multiple = $extraOrder['multiple'];
                 }
                 if (array_key_exists('infoRequired', $extraOrder)) {
                     $infoRequired = $extraOrder['infoRequired'];
                 }
             }
             $extra = Extra::findOrFail($extra_id);
             $thisExtraTotal = $extra->cost * $multiple;
             $extraSubTotal += $thisExtraTotal;
             $extras[$extra_id] = array('id' => $extra_id, 'multiple' => $multiple, 'infoRequired' => $infoRequired, 'extra' => $extra, 'thisExtraCost' => $thisExtraTotal);
         }
     }
     //Format the discounts so that the fixed and percentage discounts
     //can be applied separately, fixed first.
     $discounts = array();
     $fixedDiscounts = array();
     $percentageDiscounts = array();
     $discounts_applied = "";
     if (key_exists('discounts', $data)) {
         foreach ($data['discounts'] as $discount_id => $discountApply) {
             if ($discountApply == 1) {
                 $discount = Discount::findOrFail($discount_id);
                 $discounts[] = $discount;
                 $discounts_applied = $discounts_applied . $discount_id . "-";
             }
         }
         $discounts = collect($discounts);
         $fixedDiscounts = $discounts->where('type', 'fixed');
         $percentageDiscounts = $discounts->where('type', 'percentage');
     }
     //total (just competitions and extras)
     $compExtraSubtotal = $compSubTotal + $extraSubTotal;
     //Apply any discounts to the compextrasubtotal & registration fee
     //fixed fees first, then %.
     $discountedSubtotal = $compExtraSubtotal;
     $discountedRegistrationFee = $event->registrationFee;
     $percentageDiscountValues = array();
     foreach ($fixedDiscounts as $fd) {
         $discountedSubtotal = $discountedSubtotal - $fd->value;
     }
     foreach ($percentageDiscounts as $pd) {
         $percentage = $pd->value / 100;
         $discount = $discountedSubtotal * $percentage;
         $percentageDiscountValues[$pd->id] = $discount;
         $discountedSubtotal = $discount;
         $discountedRegistrationFee = $discountedRegistrationFee * $percentage;
     }
     //Charge a late entry fee? //if it's past the closing date
     $lateEntryFee = 0;
     if (Carbon::now()->gt($event->closingDate)) {
         $lateEntryFee = $event->lateEntriesFee;
     }
     //FORESIGHT FEE
     $foresightFee = 2.99;
     $finalsubtotal = $discountedSubtotal + $discountedRegistrationFee + $lateEntryFee + $foresightFee;
     //paypal fees (3.4% + 20p)
     $paypalFees = $finalsubtotal * 0.034 + 0.2;
     $feesTotal = $discountedRegistrationFee + $lateEntryFee + $foresightFee + $paypalFees;
     $grandTotal = $finalsubtotal + $paypalFees;
     $format = "%4.2f";
     $variables = array('entrydata' => $data, 'event' => $event, 'user' => $user, 'entries' => $entries, 'extras' => $extras, 'fixedDiscounts' => $fixedDiscounts, 'percentageDiscounts' => $percentageDiscounts, 'percentageDiscountValues' => $percentageDiscountValues, 'compSubTotal' => sprintf($format, $compSubTotal), 'extraSubTotal' => sprintf($format, $extraSubTotal), 'compExtraSubtotal' => sprintf($format, $compExtraSubtotal), 'discountedSubtotal' => sprintf($format, $discountedSubtotal), 'discountedRegistrationFee' => sprintf($format, $discountedRegistrationFee), 'lateEntryFee' => sprintf($format, $lateEntryFee), 'paypalFees' => sprintf($format, $paypalFees), 'feesTotal' => sprintf($format, $feesTotal), 'grandTotal' => sprintf($format, $grandTotal), 'discounts_applied' => $discounts_applied, 'foresightFee' => sprintf($format, $foresightFee));
     //dd($variables);
     return view('events.entryconfirm')->with($variables);
 }