/** * Get all expenses so far * in json format * * @return json */ public function getAllExpensesJson() { $response = array(array('Expense', 'Total expense')); $prediction = new Prediction(); $expenses = $prediction->getAllSpentPredictions(Auth::user()->id); if (count($expenses)) { foreach ($expenses as $expense) { $response[] = array($expense->name, (double) $expense->value); } } else { $response[] = array('Nothing', 0); } return Response::json($response); }