public function index() { $sortBy = \Request::get('sortBy', 'created_at'); $direction = \Request::get('direction', 'desc'); $dateFilter = \Request::get('date_filter', ''); $memberFilter = \Request::get('member_filter', ''); $reasonFilter = \Request::get('reason_filter', ''); $this->paymentRepository->setPerPage(50); if ($dateFilter) { $startDate = \Carbon\Carbon::createFromFormat('Y-m-d', $dateFilter)->setTime(0, 0, 0); $this->paymentRepository->dateFilter($startDate, $startDate->copy()->addMonth()); } if ($memberFilter) { $this->paymentRepository->memberFilter($memberFilter); } if ($reasonFilter) { $this->paymentRepository->reasonFilter($reasonFilter); } $payments = $this->paymentRepository->getPaginated(compact('sortBy', 'direction')); $paymentTotal = $this->paymentRepository->getTotalAmount(); $dateRangeEarliest = \Carbon\Carbon::create(2009, 07, 01); $dateRangeStart = \Carbon\Carbon::now(); $dateRange = []; while ($dateRangeStart->gt($dateRangeEarliest)) { $dateRange[$dateRangeStart->toDateString()] = $dateRangeStart->format('F Y'); $dateRangeStart->subMonth(); } $memberList = $this->userRepository->getAllAsDropdown(); $reasonList = ['subscription' => 'Subscription', 'induction' => 'Equipment Access Fee', 'balance' => 'Balance', 'door-key' => 'Key Deposit', 'storage-box' => 'Storage Box Deposit', 'equipment-fee' => 'Equipment Costs']; return \View::make('payments.index')->with('payments', $payments)->with('dateRange', $dateRange)->with('memberList', $memberList)->with('reasonList', $reasonList)->with('paymentTotal', $paymentTotal); }
public function index() { $this->paymentRepository->reasonFilter('balance'); $balancePaidIn = $this->paymentRepository->getTotalAmount(); $this->paymentRepository->resetFilters(); $this->paymentRepository->sourceFilter('balance'); $balancePaidOut = $this->paymentRepository->getTotalAmount(); $balanceLiability = $balancePaidIn - $balancePaidOut; $this->paymentRepository->resetFilters(); $this->paymentRepository->reasonFilter('storage-box'); $storageBoxLiability = $this->paymentRepository->getTotalAmount(); $this->paymentRepository->resetFilters(); $this->paymentRepository->reasonFilter('door-key'); $doorKeyLiability = $this->paymentRepository->getTotalAmount(); $laserCutterInvestment = $this->paymentRepository->getPaymentsByReference('laser-cutter')->sum('amount'); $laserCutterMoneySpent = $this->paymentRepository->getEquipmentFeePayments('laser')->sum('amount'); return \View::make('payment_overview.index')->with(compact('balancePaidIn', 'balancePaidOut', 'balanceLiability', 'storageBoxLiability', 'doorKeyLiability', 'laserCutterInvestment', 'laserCutterMoneySpent')); }