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); }