Ejemplo n.º 1
0
 public function newBudget()
 {
     $budget = new Budget();
     $budget->name = Input::get('name');
     $budget->amount = floatval(Input::get('amount'));
     $budget->fireflyuser_id = Auth::user()->id;
     $budget->date = Session::get('period')->format('Y-m') . '-01';
     $validator = Validator::make($budget->toArray(), Budget::$rules);
     if ($validator->fails()) {
         Log::error('Could not create Budget for user ' . Auth::user()->email . ': ' . print_r($validator->messages()->all(), true) . ' Budget: ' . print_r($budget, true));
         return Redirect::to('/home/budget/add')->withErrors($validator)->withInput();
     } else {
         $budget->name = Crypt::encrypt($budget->name);
         $budget->save();
         return Redirect::to('/home');
     }
 }