Skip to content

Firefly III: a personal finances manager

Removed some old code, added todo's.

James Cole15e99bd672e3
diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php
index 035400b976..938812f079 100644
--- a/app/controllers/HomeController.php
+++ b/app/controllers/HomeController.php
@@ -21,10 +21,6 @@ class HomeController extends BaseController
*/
public function index()
{
- // Event::fire('limits.check');
- // Event::fire('piggybanks.check');
- // Event::fire('recurring.check');
-
// count, maybe Firefly needs some introducing text to show:
/** @var \FireflyIII\Database\Account $acct */
$acct = App::make('FireflyIII\Database\Account');
diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.php
index 14f7be3774..4d241bca26 100644
--- a/app/controllers/PiggybankController.php
+++ b/app/controllers/PiggybankController.php
@@ -179,7 +179,7 @@ class PiggybankController extends BaseController
/*
* Create event!
*/
- Event::fire('piggybank.addMoney', [$piggybank, $amount]);
+ Event::fire('piggybank.addMoney', [$piggybank, $amount]); // new and used.
Session::flash('success', 'Added ' . mf($amount, false) . ' to "' . e($piggybank->name) . '".');
} else {
@@ -208,7 +208,7 @@ class PiggybankController extends BaseController
/*
* Create event!
*/
- Event::fire('piggybank.removeMoney', [$piggybank, $amount]);
+ Event::fire('piggybank.removeMoney', [$piggybank, $amount]); // new and used.
Session::flash('success', 'Removed ' . mf($amount, false) . ' from "' . e($piggybank->name) . '".');
} else {
@@ -279,7 +279,7 @@ class PiggybankController extends BaseController
/*
* Create the relevant repetition per Event.
*/
- Event::fire('piggybank.storePiggybank', [$piggyBank]);
+ Event::fire('piggybank.storePiggybank', [$piggyBank]); // new and used.
Session::flash('success', 'New piggy bank stored!');
diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.php
index abc61a94aa..a66077f179 100644
--- a/app/controllers/TransactionController.php
+++ b/app/controllers/TransactionController.php
@@ -103,7 +103,7 @@ class TransactionController extends BaseController
/*
* Trigger creation of new piggy bank event
*/
- Event::fire('piggybank.destroyTransfer', [$transactionJournal]);
+ Event::fire('piggybank.destroyTransfer', [$transactionJournal]); // new and used.
/** @var \FireflyIII\Database\TransactionJournal $repository */
$repository = App::make('FireflyIII\Database\TransactionJournal');
@@ -320,7 +320,7 @@ class TransactionController extends BaseController
* piggy bank and store an event.
*/
if (!is_null(Input::get('piggybank_id')) && intval(Input::get('piggybank_id')) > 0) {
- Event::fire('piggybank.storeTransfer', [$journal, intval(Input::get('piggybank_id'))]);
+ Event::fire('piggybank.storeTransfer', [$journal, intval(Input::get('piggybank_id'))]); // new and used.
}
if ($data['post_submit_action'] == 'create_another') {
@@ -363,8 +363,7 @@ class TransactionController extends BaseController
if ($messageBag->count() == 0) {
// has been saved, return to index:
Session::flash('success', 'Transaction updated!');
- // Event::fire('journals.update', [$journal]);
- Event::fire('piggybank.updateTransfer', [$journal]);
+ Event::fire('piggybank.updateTransfer', [$journal]); // new and used.
if (Input::get('post_submit_action') == 'return_to_edit') {
return Redirect::route('transactions.edit', $journal->id)->withInput();
diff --git a/app/database/migrations/2014_11_13_062347_expand_reminders_table.php b/app/database/migrations/2014_11_13_062347_expand_reminders_table.php
index 44274fdb1c..c6e7993b50 100644
--- a/app/database/migrations/2014_11_13_062347_expand_reminders_table.php
+++ b/app/database/migrations/2014_11_13_062347_expand_reminders_table.php
@@ -23,7 +23,7 @@ class ExpandRemindersTable extends Migration
public function up()
{
Schema::table(
- 'reminders', function ($table) {
+ 'reminders', function (Blueprint $table) {
$table->string('title');
$table->text('data');
}
diff --git a/app/database/migrations/2014_11_15_112449_extend_piggybank_events.php b/app/database/migrations/2014_11_15_112449_extend_piggybank_events.php
index c92d1f0343..5fc8ea6f96 100644
--- a/app/database/migrations/2014_11_15_112449_extend_piggybank_events.php
+++ b/app/database/migrations/2014_11_15_112449_extend_piggybank_events.php
@@ -23,7 +23,7 @@ class ExtendPiggybankEvents extends Migration
public function up()
{
Schema::table(
- 'piggybank_events', function ($table) {
+ 'piggybank_events', function (Blueprint $table) {
$table->integer('transaction_journal_id')->unsigned()->nullable();
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('set null');
}
diff --git a/app/database/migrations/2014_11_17_194734_event_table_additions_1.php b/app/database/migrations/2014_11_17_194734_event_table_additions_1.php
new file mode 100644
index 0000000000..3ae334b60e
--- /dev/null
+++ b/app/database/migrations/2014_11_17_194734_event_table_additions_1.php
@@ -0,0 +1,37 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+
+class EventTableAdditions1 extends Migration
+{
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ //
+ }
+
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ // remove some fields:
+ Schema::table(
+ 'reminders', function (Blueprint $table) {
+ $table->dropColumn('title');
+ $table->dropColumn('data');
+ $table->integer('remembersable_id')->unsigned()->nullable();
+ $table->string('remembersable_type');
+ }
+ );
+ }
+
+}
diff --git a/app/models/Limit.php b/app/models/Limit.php
index 2e1f1f604f..06c644e54b 100644
--- a/app/models/Limit.php
+++ b/app/models/Limit.php
@@ -100,7 +100,7 @@ class Limit extends Ardent
\Log::error($e->getMessage());
}
if (isset($repetition->id)) {
- \Event::fire('limits.repetition', [$repetition]);
+ \Event::fire('limits.repetition', [$repetition]); // not used, I guess?
}
} else {
if ($count == 1) {
diff --git a/app/models/Piggybank.php b/app/models/Piggybank.php
index 1e35e41081..ff4adc609a 100644
--- a/app/models/Piggybank.php
+++ b/app/models/Piggybank.php
@@ -81,6 +81,11 @@ class Piggybank extends Ardent
}
+ public function reminders()
+ {
+ return $this->morphMany('Reminder', 'remembersable');
+ }
+
/**
* TODO remove this method in favour of something in the FireflyIII libraries.
*
diff --git a/app/models/Reminder.php b/app/models/Reminder.php
index 9b6634fc0b..79c8aa8186 100644
--- a/app/models/Reminder.php
+++ b/app/models/Reminder.php
@@ -2,30 +2,6 @@
use LaravelBook\Ardent\Ardent;
-
-/**
- * Reminder
- *
- * @property integer $id
- * @property \Carbon\Carbon $created_at
- * @property \Carbon\Carbon $updated_at
- * @property integer $user_id
- * @property \Carbon\Carbon $startdate
- * @property \Carbon\Carbon $enddate
- * @property boolean $active
- * @property string $title
- * @property string $data
- * @property-read \User $user
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereId($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereCreatedAt($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereUpdatedAt($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereUserId($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereStartdate($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereEnddate($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereActive($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereTitle($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereData($value)
- */
class Reminder extends Ardent
{
@@ -40,6 +16,16 @@ class Reminder extends Ardent
return ['created_at', 'updated_at', 'startdate', 'enddate'];
}
+ /**
+ * A polymorphic thing or something!
+ *
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function remindersable()
+ {
+ return $this->morphTo();
+ }
+
/**
* User
*
diff --git a/bootstrap/start.php b/bootstrap/start.php
index 38c19a0300..5a7761f3ab 100644
--- a/bootstrap/start.php
+++ b/bootstrap/start.php
@@ -103,4 +103,5 @@ Event::subscribe('FireflyIII\Event\Piggybank');
// TODO check if recurring transactions are being updated when journals are updated (aka no longer fitting, thus removed).
// TODO think about reminders.
// TODO an event that triggers and creates a limit + limit repetition when a budget is created, or something?
+// TODO has many through needs to be added wherever relevant. Account > journals, etc.
return $app;