/** * Homepage Method * @method index * @return view The homepage HTML. */ public function index() { // TODO: optimize these queries. // TODO: Decide whether or now to show a monthly earnings, instead of // just a weekly breakdown of the totals. $data['incomes'] = Income::all()->sortByDesc('amount'); $data['expenses'] = Expense::all()->sortByDesc('amount'); $data['totalIncome'] = DB::table('incomes')->sum('amount') / 4; $data['totalExpenses'] = DB::table('expenses')->sum('amount') / 4; $data['weeklyWorth'] = $data['totalIncome'] - $data['totalExpenses']; return view('index', $data); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $incomes = Income::all()->sortByDesc('amount'); return view('incomes/index')->with('incomes', $incomes); }