/**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $installations = \App\Basket\Installation::all();
     /** @var \App\Basket\Installation $installation */
     foreach ($installations as $installation) {
         $bitwise = \PayBreak\Foundation\Properties\Bitwise::make($installation->finance_offers);
         if ($bitwise->contains(\App\Basket\Installation::LINK) || $bitwise->contains(\App\Basket\Installation::EMAIL)) {
             $bitwise->remove(\App\Basket\Installation::LINK);
             $bitwise->remove(\App\Basket\Installation::EMAIL);
             $total = $bitwise->get() + (\App\Basket\Installation::LINK + \App\Basket\Installation::EMAIL);
             $installation->finance_offers = $total;
             $installation->save();
         }
     }
 }
 /**
  * @author WN
  * @param int $locationId
  * @param Request $request
  * @param bool $assisted
  * @return \Illuminate\Http\JsonResponse
  * @throws RedirectException
  */
 public function chooseProduct($locationId, Request $request, $assisted = false)
 {
     $this->validate($request, ['amount' => 'required|numeric']);
     $location = $this->fetchLocation($locationId);
     return view('initialise.main')->with(['options' => $this->getCreditInfoWithProductLimits($location->installation, $request->get('amount') * 100), 'flexibleFinance' => $this->prepareFlexibleFinance($location, $request->get('amount') * 100), 'amount' => floor($request->get('amount') * 100), 'location' => $location, 'bitwise' => Bitwise::make($location->installation->finance_offers), 'reference' => $this->generateOrderReferenceFromLocation($location), 'assisted' => $assisted]);
 }
Example #3
0
 /**
  * Return an array of Finance Offers (from bitwise stored)
  *
  * @author EB
  * @return array
  */
 public function getBitwiseFinanceOffers()
 {
     $financeOffers = Bitwise::make($this->finance_offers);
     return ['in_store' => ['value' => self::IN_STORE, 'active' => $financeOffers->contains(self::IN_STORE), 'text' => 'Continue with In-store Application'], 'link' => ['value' => self::LINK, 'active' => $financeOffers->contains(self::LINK), 'text' => 'Create Application Link', 'name' => 'link'], 'email' => ['value' => self::EMAIL, 'active' => $financeOffers->contains(self::EMAIL), 'text' => 'Email Application', 'name' => 'email']];
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\View\View
  */
 public function edit($id)
 {
     $installation = $this->fetchInstallation($id);
     return view('installations.edit', ['installations' => $installation, 'emailConfigHelper' => EmailConfigurationTemplateHelper::makeFromJson($installation->email_configuration), 'bitwise' => Bitwise::make($installation->finance_offers)]);
 }