Also create routine for repeated expenses. [skip ci] issue #6

This commit is contained in:
James Cole
2014-08-14 18:17:02 +02:00
parent e063e5686f
commit 12e5f80d80
3 changed files with 68 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
<?php
use Carbon\Carbon;
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
use Firefly\Storage\Piggybank\PiggybankRepositoryInterface as PRI;
@@ -129,19 +130,23 @@ class PiggybankController extends BaseController
/**
* @return $this|\Illuminate\Http\RedirectResponse
*/
public function store()
public function storeRepeated()
{
$piggyBank = $this->_repository->store(Input::all());
$data = Input::all();
unset($data['_token']);
// extend the data array with the settings needed to create a repeated:
$data['repeats'] = 1;
$data['startdate'] = new Carbon;
$data['order'] = 0;
$piggyBank = $this->_repository->store($data);
if ($piggyBank->validate()) {
Session::flash('success', 'New piggy bank "' . $piggyBank->name . '" created!');
if (Input::get('create') == '1') {
return Redirect::route('piggybanks.create')->withInput();
}
return Redirect::route('piggybanks.index');
} else {
Session::flash('error', 'Could not save piggy bank: ' . $piggyBank->errors()->first());