Remove reminders when piggy bank is reminded.

This commit is contained in:
James Cole 2015-03-31 20:22:51 +02:00
parent e11e53913a
commit 02e55496df
2 changed files with 14 additions and 3 deletions

View File

@ -15,6 +15,8 @@ use Redirect;
use Response;
use Session;
use View;
use URL;
/**
* Class TransactionController
@ -291,7 +293,7 @@ class TransactionController extends Controller
return Redirect::route('transactions.create', $request->input('what'))->withInput();
}
return Redirect::route('transactions.index', $request->input('what'));
return Redirect::to(URL::previous());
}
@ -318,7 +320,7 @@ class TransactionController extends Controller
}
return Redirect::route('transactions.index', $journalData['what']);
return Redirect::to(URL::previous());
}

View File

@ -12,7 +12,7 @@ use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Log;
use Reminder;
/**
* Class EventServiceProvider
*
@ -60,6 +60,15 @@ class EventServiceProvider extends ServiceProvider
);
PiggyBank::deleting(function(PiggyBank $piggyBank) {
$reminders = $piggyBank->reminders()->get();
/** @var Reminder $reminder */
foreach($reminders as $reminder) {
$reminder->delete();
}
});
Account::deleted(
function (Account $account) {