Removed some old code, added todo's.

This commit is contained in:
James Cole
2014-11-17 20:55:31 +01:00
parent 696e9a6fde
commit 15e99bd672
10 changed files with 62 additions and 38 deletions

View File

@@ -21,10 +21,6 @@ class HomeController extends BaseController
*/ */
public function index() public function index()
{ {
// Event::fire('limits.check');
// Event::fire('piggybanks.check');
// Event::fire('recurring.check');
// count, maybe Firefly needs some introducing text to show: // count, maybe Firefly needs some introducing text to show:
/** @var \FireflyIII\Database\Account $acct */ /** @var \FireflyIII\Database\Account $acct */
$acct = App::make('FireflyIII\Database\Account'); $acct = App::make('FireflyIII\Database\Account');

View File

@@ -179,7 +179,7 @@ class PiggybankController extends BaseController
/* /*
* Create event! * 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) . '".'); Session::flash('success', 'Added ' . mf($amount, false) . ' to "' . e($piggybank->name) . '".');
} else { } else {
@@ -208,7 +208,7 @@ class PiggybankController extends BaseController
/* /*
* Create event! * 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) . '".'); Session::flash('success', 'Removed ' . mf($amount, false) . ' from "' . e($piggybank->name) . '".');
} else { } else {
@@ -279,7 +279,7 @@ class PiggybankController extends BaseController
/* /*
* Create the relevant repetition per Event. * 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!'); Session::flash('success', 'New piggy bank stored!');

View File

@@ -103,7 +103,7 @@ class TransactionController extends BaseController
/* /*
* Trigger creation of new piggy bank event * 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 */ /** @var \FireflyIII\Database\TransactionJournal $repository */
$repository = App::make('FireflyIII\Database\TransactionJournal'); $repository = App::make('FireflyIII\Database\TransactionJournal');
@@ -320,7 +320,7 @@ class TransactionController extends BaseController
* piggy bank and store an event. * piggy bank and store an event.
*/ */
if (!is_null(Input::get('piggybank_id')) && intval(Input::get('piggybank_id')) > 0) { 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') { if ($data['post_submit_action'] == 'create_another') {
@@ -363,8 +363,7 @@ class TransactionController extends BaseController
if ($messageBag->count() == 0) { if ($messageBag->count() == 0) {
// has been saved, return to index: // has been saved, return to index:
Session::flash('success', 'Transaction updated!'); Session::flash('success', 'Transaction updated!');
// Event::fire('journals.update', [$journal]); Event::fire('piggybank.updateTransfer', [$journal]); // new and used.
Event::fire('piggybank.updateTransfer', [$journal]);
if (Input::get('post_submit_action') == 'return_to_edit') { if (Input::get('post_submit_action') == 'return_to_edit') {
return Redirect::route('transactions.edit', $journal->id)->withInput(); return Redirect::route('transactions.edit', $journal->id)->withInput();

View File

@@ -23,7 +23,7 @@ class ExpandRemindersTable extends Migration
public function up() public function up()
{ {
Schema::table( Schema::table(
'reminders', function ($table) { 'reminders', function (Blueprint $table) {
$table->string('title'); $table->string('title');
$table->text('data'); $table->text('data');
} }

View File

@@ -23,7 +23,7 @@ class ExtendPiggybankEvents extends Migration
public function up() public function up()
{ {
Schema::table( Schema::table(
'piggybank_events', function ($table) { 'piggybank_events', function (Blueprint $table) {
$table->integer('transaction_journal_id')->unsigned()->nullable(); $table->integer('transaction_journal_id')->unsigned()->nullable();
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('set null'); $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('set null');
} }

View File

@@ -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');
}
);
}
}

View File

@@ -100,7 +100,7 @@ class Limit extends Ardent
\Log::error($e->getMessage()); \Log::error($e->getMessage());
} }
if (isset($repetition->id)) { if (isset($repetition->id)) {
\Event::fire('limits.repetition', [$repetition]); \Event::fire('limits.repetition', [$repetition]); // not used, I guess?
} }
} else { } else {
if ($count == 1) { if ($count == 1) {

View File

@@ -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. * TODO remove this method in favour of something in the FireflyIII libraries.
* *

View File

@@ -2,30 +2,6 @@
use LaravelBook\Ardent\Ardent; 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 class Reminder extends Ardent
{ {
@@ -40,6 +16,16 @@ class Reminder extends Ardent
return ['created_at', 'updated_at', 'startdate', 'enddate']; 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 * User
* *

View File

@@ -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 check if recurring transactions are being updated when journals are updated (aka no longer fitting, thus removed).
// TODO think about reminders. // TODO think about reminders.
// TODO an event that triggers and creates a limit + limit repetition when a budget is created, or something? // 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; return $app;