/** * @author WN * @param int $application * @return Application */ protected function fetchApplicationByExternalId($application) { $app = Application::where('ext_id', $application)->get(); if (count($app) == 1) { return $app[0]; } throw new ModelNotFoundException('Application ' . $application . ' not found.'); }
/** * Index * * @author MS * @param int $id * @return \Illuminate\View\View * @throws \App\Exceptions\RedirectException */ public function index($id) { $dateRange = $this->getDateRange(); try { $settlementReports = Collection::make($this->settlementGateway->getSettlementReports($this->fetchMerchantById($id)->token, $dateRange['date_from'], $dateRange['date_to'])); } catch (\Exception $e) { $this->logError('SettlementsController: failed fetching settlements' . $e->getMessage()); throw RedirectException::make('/')->setError('Problem fetching Settlements.'); } $filter = $this->getFilters(); if (!$filter->isEmpty()) { $settlementReports = $settlementReports->filter(function ($settlement_reports) use($filter) { if ($settlement_reports['provider'] == $filter['provider']) { return true; } }); } $local = []; foreach ($settlementReports as $key => $report) { $settlementReports[$key] = (object) $report; $local[$report['id']] = Application::where('ext_id', '=', $report['id'])->first(); } return View('settlements.index', ['settlement_reports' => $settlementReports, 'default_dates' => $this->getDateRange(), 'provider' => $this->fetchFilterValues($settlementReports, 'provider'), 'local' => $local]); }
/** * @param $id * @return Application * @throws ModelNotFoundException * @throws \Exception */ private function fetchApplicationLocalObject($id) { try { return Application::findOrFail($id); } catch (ModelNotFoundException $e) { $this->logError(__CLASS__ . ': Failed fetching Installation[' . $id . '] local object: ' . $e->getMessage()); throw $e; } }
/** * @author EB * @param $id * @param string $field * @return Application */ protected function fetchApplicationDetails($id, $field = 'ext_id') { return Application::where($field, '=', $id)->first(); }
/** * @author EB * @param Request $request * @param Location $location * @return bool * @throws RedirectException */ private function validateApplicationRequest(Request $request, Location $location) { /** @var Application $application */ if ($application = Application::where('ext_order_reference', '=', $request->get('reference'))->where('installation_id', '=', $location->installation->id)->first()) { throw RedirectException::make('/locations/' . $location->id . '/applications/make')->setError('Unable to process the request, an application has already been created with this order reference (<a href="/installations/' . $location->installation->id . '/applications/' . $application->id . '">' . $application->ext_order_reference . '</a>)'); } return true; }
public static function getEvents(Application $application) { return $application->applicationEvents()->orderByRaw('created_at ASC, id ASC')->get(); }
/** * @author SL * * @param int $installation * @param int $id * * @return \Illuminate\View\View */ public function addMerchantPayment($installation, $id) { return view('applications.merchant-payment', ['application' => Application::find($id)]); }
/** * Show a Partial Refund * * @author LH * @param int $merchant * @param int $partialRefundId * @return \Illuminate\View\View */ public function show($merchant, $partialRefundId) { $partialRefund = $this->partialRefundGateway->getPartialRefund($this->fetchMerchantById($merchant)->token, $partialRefundId); return View('partial-refunds.show', ['partialRefund' => (object) $partialRefund->toArray(), 'installation' => Application::where('ext_id', '=', $partialRefund->toArray()['application'])->first()]); }