public function home(Budget $budget) { // $budgets=Budget::orderBy('start_date','desc') // ->get(); //dd($budget->displayBudgetData()); $budgets = json_encode($budget->displayBudgetData()); return view('pages.home', compact('budgets')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // $budget = Budget::findOrFail($id); $dailyExpenses = json_encode(DailyExpense::addAndGroup($budget->id)); //dd($dailyExpenses); return view('budgets.show', compact('budget', 'dailyExpenses')); }
/** * list related expenses to the budget & category */ public function listRelatedExpenses($budgetId, $category) { $budget = Budget::findOrFail($budgetId); $expenses = json_encode(DailyExpense::category($budgetId, $category)); //dd($budget); //dd(DailyExpense::category(1,'Food')); return view('dailyExpenses.listAllExpenses', compact('budget', 'expenses', 'category')); }
/** * Delete a budget */ public function deleteBudget() { $budget = Budget::find(Input::get('id')); if (!$budget) { return Redirect::to(route('get_budgets')); } if ($budget->rejected > 0) { return Redirect::to(route('get_budgets'))->withErrors(trans('validation.budgets.rejectedAccepted')); } $budget->delete(); return Redirect::to(route('get_budgets'))->with('message', trans('budgets.recDeleted'))->with('masterBriefingId', Input::get('masterBriefingId')); }
public function update(Budget $budget, BudgetRequest $request) { $budget->update($request->all()); return redirect('budgets'); }
public function removeBudget(Request $request) { $id = $request->input('id'); $budget = Budget::where('id', $id)->first(); if (isset($budget)) { $budget->status = 'removed'; $budget->save(); return json_encode(array('message' => 'removed')); } else { return json_encode(array('message' => 'notfound', 'id' => $id)); } }
public function cancelBudget($id) { $budget = Budget::find($id); $budget->status = "Nulo"; $budget->save(); return "Actualizado"; }