// is a User related event. [ 'FireflyIII\Handlers\Events\UserEventHandler@sendRegistrationMail', 'FireflyIII\Handlers\Events\UserEventHandler@attachUserRole', ], 'FireflyIII\Events\RequestedNewPassword' => [ // is a User related event. 'FireflyIII\Handlers\Events\UserEventHandler@sendNewPassword', ], 'FireflyIII\Events\StoredTransactionJournal' => // is a Transaction Journal related event. [ 'FireflyIII\Handlers\Events\StoredJournalEventHandler@scanBills', 'FireflyIII\Handlers\Events\StoredJournalEventHandler@connectToPiggyBank', 'FireflyIII\Handlers\Events\StoredJournalEventHandler@processRules', ], 'FireflyIII\Events\UpdatedTransactionJournal' => // is a Transaction Journal related event. [ 'FireflyIII\Handlers\Events\UpdatedJournalEventHandler@scanBills', 'FireflyIII\Handlers\Events\UpdatedJournalEventHandler@processRules', ], ]; /** * Register any events for your application. * * @return void */ public function boot() { parent::boot(); $this->registerDeleteEvents(); $this->registerCreateEvents(); } /** * */ protected function registerCreateEvents() { // move this routine to a filter // in case of repeated piggy banks and/or other problems. PiggyBank::created( function (PiggyBank $piggyBank) { $repetition = new PiggyBankRepetition; $repetition->piggyBank()->associate($piggyBank); $repetition->startdate = is_null($piggyBank->startdate) ? null : $piggyBank->startdate; $repetition->targetdate = is_null($piggyBank->targetdate) ? null : $piggyBank->targetdate; $repetition->currentamount = 0; $repetition->save(); } ); } /** * */ protected function registerDeleteEvents() { Account::deleted( function (Account $account) { Log::debug('Now trigger account delete response #' . $account->id); /** @var Transaction $transaction */ foreach ($account->transactions()->get() as $transaction) { Log::debug('Now at transaction #' . $transaction->id); $journal = $transaction->transactionJournal()->first(); if (!is_null($journal)) { Log::debug('Call for deletion of journal #' . $journal->id); $journal->delete(); } } } ); TransactionJournal::deleted( function (TransactionJournal $journal) { Log::debug(sprintf('Now triggered journal delete response #%d', $journal->id)); /** @var Transaction $transaction */ foreach ($journal->transactions()->get() as $transaction) { Log::debug(sprintf('Will now delete transaction #%d', $transaction->id)); $transaction->delete(); } // also delete journal_meta entries. /** @var TransactionJournalMeta $meta */ foreach ($journal->transactionJournalMeta()->get() as $meta) { Log::debug(sprintf('Will now delete meta-entry #%d', $meta->id)); $meta->delete(); } } ); } }