diff --git a/app/database/migrations/2014_06_27_163818_create_piggybanks_table.php b/app/database/migrations/2014_06_27_163818_create_piggybanks_table.php index e4f2be8348..c45cddac73 100644 --- a/app/database/migrations/2014_06_27_163818_create_piggybanks_table.php +++ b/app/database/migrations/2014_06_27_163818_create_piggybanks_table.php @@ -38,10 +38,10 @@ class CreatePiggybanksTable extends Migration $table->date('startdate')->nullable(); $table->date('targetdate')->nullable(); $table->boolean('repeats'); - $table->enum('rep_length', ['day', 'week', 'month', 'year'])->nullable(); + $table->enum('rep_length', ['day', 'week','quarter', 'month', 'year'])->nullable(); $table->smallInteger('rep_every')->unsigned(); $table->smallInteger('rep_times')->unsigned()->nullable(); - $table->enum('reminder', ['day', 'week', 'month', 'year'])->nullable(); + $table->enum('reminder', ['day', 'week','quarter', 'month', 'year'])->nullable(); $table->smallInteger('reminder_skip')->unsigned(); $table->boolean('remind_me'); $table->integer('order')->unsigned(); diff --git a/app/lib/FireflyIII/Shared/Toolkit/Reminders.php b/app/lib/FireflyIII/Shared/Toolkit/Reminders.php index 52998712f5..f18851e342 100644 --- a/app/lib/FireflyIII/Shared/Toolkit/Reminders.php +++ b/app/lib/FireflyIII/Shared/Toolkit/Reminders.php @@ -104,7 +104,7 @@ class Reminders } $end = \DateKit::endOfPeriod(clone $start, $piggybank->reminder); // should have a reminder for this period: - /** @var \Collection $reminders */ + /** @var Collection $reminders */ $reminders = $piggybank->reminders()->dateIs($start, $end)->get(); if ($reminders->count() == 0) { // create new! @@ -113,7 +113,8 @@ class Reminders $reminder->enddate = $end; $reminder->active = 1; $reminder->user()->associate($repository->getUser()); - $reminder->remindersable()->associate($piggybank); + $reminder->remindersable_id= $piggybank->id; + $reminder->remindersable_type = 'Piggybank'; $reminder->save(); } } diff --git a/app/models/Account.php b/app/models/Account.php index 3f2d087fee..bffa32415f 100644 --- a/app/models/Account.php +++ b/app/models/Account.php @@ -17,14 +17,14 @@ use LaravelBook\Ardent\Builder; * @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions * @property-read \Illuminate\Database\Eloquent\Collection|\Piggybank[] $piggybanks * @property-read \User $user - * @method static \Illuminate\Database\Query\Builder|\Account whereId($value) - * @method static \Illuminate\Database\Query\Builder|\Account whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Account whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Account whereUserId($value) - * @method static \Illuminate\Database\Query\Builder|\Account whereAccountTypeId($value) - * @method static \Illuminate\Database\Query\Builder|\Account whereName($value) - * @method static \Illuminate\Database\Query\Builder|\Account whereActive($value) - * @method static \Account accountTypeIn($types) + * @method static \Illuminate\Database\Query\Builder|\Account whereId($value) + * @method static \Illuminate\Database\Query\Builder|\Account whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Account whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Account whereUserId($value) + * @method static \Illuminate\Database\Query\Builder|\Account whereAccountTypeId($value) + * @method static \Illuminate\Database\Query\Builder|\Account whereName($value) + * @method static \Illuminate\Database\Query\Builder|\Account whereActive($value) + * @method static \Account accountTypeIn($types) */ class Account extends Ardent { diff --git a/app/models/PiggybankRepetition.php b/app/models/PiggybankRepetition.php index ef9557bfa1..eac5577386 100644 --- a/app/models/PiggybankRepetition.php +++ b/app/models/PiggybankRepetition.php @@ -21,6 +21,8 @@ use LaravelBook\Ardent\Builder; * @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereStartdate($value) * @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereTargetdate($value) * @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereCurrentamount($value) + * @method static \PiggybankRepetition starts($date) + * @method static \PiggybankRepetition targets($date) */ class PiggybankRepetition extends Ardent { diff --git a/app/models/Reminder.php b/app/models/Reminder.php index 7a772d1111..01b6053f16 100644 --- a/app/models/Reminder.php +++ b/app/models/Reminder.php @@ -3,6 +3,7 @@ use Carbon\Carbon; use LaravelBook\Ardent\Ardent; + /** * Reminder * @@ -14,25 +15,22 @@ use LaravelBook\Ardent\Ardent; * @property \Carbon\Carbon $enddate * @property boolean $active * @property boolean $notnow - * @property integer $remembersable_id - * @property string $remembersable_type - * @property-read \Piggybank $remindersable - * @property-read \User $user - * @property mixed $data - * @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 whereRemembersableId($value) - * @method static \Illuminate\Database\Query\Builder|\Reminder whereRemembersableType($value) - * @method static \Reminder dateIs($start, $end) * @property integer $remindersable_id * @property string $remindersable_type - * @method static \Illuminate\Database\Query\Builder|\Reminder whereRemindersableId($value) - * @method static \Illuminate\Database\Query\Builder|\Reminder whereRemindersableType($value) + * @property-read \ $remindersable + * @property-read \User $user + * @property mixed $data + * @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 whereNotnow($value) + * @method static \Illuminate\Database\Query\Builder|\Reminder whereRemindersableId($value) + * @method static \Illuminate\Database\Query\Builder|\Reminder whereRemindersableType($value) + * @method static \Reminder dateIs($start, $end) */ class Reminder extends Ardent { diff --git a/app/models/TransactionGroup.php b/app/models/TransactionGroup.php index bb29b3f3b4..10d363eb72 100644 --- a/app/models/TransactionGroup.php +++ b/app/models/TransactionGroup.php @@ -1,6 +1,22 @@ hasManyThrough('Piggybank', 'Account'); } - public function transactions() - { - return $this->hasManyThrough('TransactionJournal', 'Transaction'); - } /** * @return \Illuminate\Database\Eloquent\Relations\HasMany @@ -126,7 +122,6 @@ class User extends Ardent implements UserInterface, RemindableInterface return $this->hasMany('Reminder'); } - /** * @param $value */ @@ -143,4 +138,9 @@ class User extends Ardent implements UserInterface, RemindableInterface return $this->hasMany('TransactionJournal'); } + public function transactions() + { + return $this->hasManyThrough('TransactionJournal', 'Transaction'); + } + } \ No newline at end of file