_budgets = $budgets; $this->_limits = $limits; View::share('menu', 'budgets'); } public function create($budgetId = null) { $periods = [ 'weekly' => 'A week', 'monthly' => 'A month', 'quarterly' => 'A quarter', 'half-year' => 'Six months', 'yearly' => 'A year', ]; $budget = $this->_budgets->find($budgetId); $budget_id = is_null($budget) ? null : $budget->id; $budgets = $this->_budgets->getAsSelectList(); return View::make('limits.create')->with('budgets', $budgets)->with('budget_id', $budget_id)->with( 'periods', $periods ); } public function store() { // find a limit with these properties, as we might already have one: $limit = $this->_limits->store(Input::all()); if ($limit->id) { return Redirect::route('budgets.index'); } else { return Redirect::route('budgets.limits.create')->withInput(); } } }