mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code for #1010
This commit is contained in:
parent
24b63abf2f
commit
8f80ee25c2
@ -170,16 +170,21 @@ class PiggyBankController extends Controller
|
||||
$subTitle = trans('firefly.update_piggy_title', ['name' => $piggyBank->name]);
|
||||
$subTitleIcon = 'fa-pencil';
|
||||
$targetDate = null;
|
||||
$startDate = null;
|
||||
$note = $piggyBank->notes()->first();
|
||||
// Flash some data to fill the form.
|
||||
if (null !== $piggyBank->targetdate) {
|
||||
$targetDate = $piggyBank->targetdate->format('Y-m-d');
|
||||
}
|
||||
if (null !== $piggyBank->startdate) {
|
||||
$startDate = $piggyBank->startdate->format('Y-m-d');
|
||||
}
|
||||
|
||||
$preFilled = ['name' => $piggyBank->name,
|
||||
'account_id' => $piggyBank->account_id,
|
||||
'targetamount' => $piggyBank->targetamount,
|
||||
'targetdate' => $targetDate,
|
||||
'startdate' => $startDate,
|
||||
'note' => null === $note ? '' : $note->text,
|
||||
];
|
||||
Session::flash('preFilled', $preFilled);
|
||||
@ -390,9 +395,13 @@ class PiggyBankController extends Controller
|
||||
*/
|
||||
public function store(PiggyBankFormRequest $request, PiggyBankRepositoryInterface $repository)
|
||||
{
|
||||
$data = $request->getPiggyBankData();
|
||||
$data = $request->getPiggyBankData();
|
||||
if (null === $data['startdate']) {
|
||||
$data['startdate'] = new Carbon;
|
||||
}
|
||||
$piggyBank = $repository->store($data);
|
||||
|
||||
|
||||
Session::flash('success', strval(trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name])));
|
||||
Preferences::mark();
|
||||
|
||||
|
@ -45,7 +45,7 @@ class PiggyBankFormRequest extends Request
|
||||
{
|
||||
return [
|
||||
'name' => $this->string('name'),
|
||||
'startdate' => new Carbon,
|
||||
'startdate' => $this->date('startdate'),
|
||||
'account_id' => $this->integer('account_id'),
|
||||
'targetamount' => $this->string('targetamount'),
|
||||
'targetdate' => $this->date('targetdate'),
|
||||
|
@ -91,6 +91,7 @@ return [
|
||||
'deletePermanently' => 'Delete permanently',
|
||||
'cancel' => 'Cancel',
|
||||
'targetdate' => 'Target date',
|
||||
'startdate' => 'Start date',
|
||||
'tag' => 'Tag',
|
||||
'under' => 'Under',
|
||||
'symbol' => 'Symbol',
|
||||
|
@ -32,6 +32,7 @@
|
||||
<h3 class="box-title">{{ 'optionalFields'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{{ ExpandedForm.date('startdate') }}
|
||||
{{ ExpandedForm.date('targetdate') }}
|
||||
{{ ExpandedForm.textarea('note', null, {helpText: trans('firefly.field_supports_markdown')}) }}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user