accounts()->accountTypeIn(['Default account', 'Asset account'])->where('active', 1)->orderBy('name', 'DESC')->get() ); $budgets = ExpandedForm::makeSelectList(Auth::user()->budgets()->get()); $budgets[0] = '(no budget)'; $piggies = ExpandedForm::makeSelectList(Auth::user()->piggyBanks()->get()); $piggies[0] = '(no piggy bank)'; $preFilled = Session::has('preFilled') ? Session::get('preFilled') : []; $respondTo = ['account_id', 'account_from_id']; $subTitle = 'Add a new ' . e($what); foreach ($respondTo as $r) { if (!is_null(Input::get($r))) { $preFilled[$r] = Input::get($r); } } Session::put('preFilled', $preFilled); asort($piggies); return view('transactions.create', compact('accounts', 'budgets', 'what', 'piggies', 'subTitle')); } /** * @param $what * * @return $this */ public function index($what) { switch ($what) { case 'expenses': case 'withdrawal': $subTitleIcon = 'fa-long-arrow-left'; $subTitle = 'Expenses'; //$journals = $this->_repository->getWithdrawalsPaginated(50); $types = ['Withdrawal']; break; case 'revenue': case 'deposit': $subTitleIcon = 'fa-long-arrow-right'; $subTitle = 'Revenue, income and deposits'; // $journals = $this->_repository->getDepositsPaginated(50); $types = ['Deposit']; break; case 'transfer': case 'transfers': $subTitleIcon = 'fa-arrows-h'; $subTitle = 'Transfers'; //$journals = $this->_repository->getTransfersPaginated(50); $types = ['Transfer']; break; } $page = intval(\Input::get('page')); $offset = $page > 0 ? ($page - 1) * 50 : 0; $set = Auth::user()->transactionJournals()->transactionTypes($types)->withRelevantData()->take(50)->offset($offset)->orderBy('date', 'DESC')->get( ['transaction_journals.*'] ); $count = Auth::user()->transactionJournals()->transactionTypes($types)->count(); $journals = new LengthAwarePaginator($set, $count, 50, $page); $journals->setPath('transactions/' . $what); return View::make('transactions.index', compact('subTitle', 'what', 'subTitleIcon', 'journals')); } }