Form for issue #6 is complete, final checks about to be written. Mebbe tomorrow. [skip ci]

This commit is contained in:
James Cole
2014-08-13 21:35:05 +02:00
parent aa55827bfc
commit 2b42cb8ef3
5 changed files with 34 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
<?php
namespace Firefly\Storage\Piggybank;
use Carbon\Carbon;
/**
@@ -74,7 +75,19 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
$piggyBank = new \Piggybank($data);
$piggyBank->account()->associate($account);
$today = new Carbon;
if ($piggyBank->validate()) {
echo 'Valid, but some more checking!';
if($piggyBank->targetdate < $today) {
$piggyBank->errors()->add('targetdate','Target date cannot be in the past.');
echo 'errrrrrr on target date';
return $piggyBank;
}
// first period for reminder is AFTER target date.
// just flash a warning
die('Here be a check. Sorry for the kill-switch. Will continue tomorrow.');
$piggyBank->save();
}