예제 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     try {
         $this->accountService->validateInput($request->all(), true, $id);
     } catch (\Exception $e) {
         abort(422);
     }
     $response = $this->accountService->update($request, $id);
     return response()->json($response);
 }
예제 #2
0
 private function getDestination($input)
 {
     $destination = null;
     switch ($input->source_type) {
         case 'credit_card':
             $destination = $this->statement_service->get($input->source_id, $input->date);
             break;
         case 'account':
             $destination = $this->account_service->get($input->source_id);
             break;
     }
     return $destination;
 }
예제 #3
0
 private function getSource($input)
 {
     $source = null;
     $amount = 0;
     if ($input->type == 'simple') {
         $amount = $input->amount;
     } else {
         foreach ($input->items as $item) {
             $amount += $item['amount'];
         }
     }
     switch ($input->source_type) {
         case 'credit_card':
             $source = $this->credit_card_purchase_service->get($input->source_id, $input->date, $amount, $input->number_installments);
             break;
         case 'account':
             $source = $this->account_service->get($input->source_id);
             break;
     }
     return $source;
 }