diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.php index 4d241bca26..f94e1368d1 100644 --- a/app/controllers/PiggybankController.php +++ b/app/controllers/PiggybankController.php @@ -27,7 +27,7 @@ class PiggybankController extends BaseController */ public function add(Piggybank $piggybank) { - /** @var \FireflyIII\Database\Piggybank $acct */ + /** @var \FireflyIII\Database\Piggybank $repos */ $repos = App::make('FireflyIII\Database\Piggybank'); $leftOnAccount = $repos->leftOnAccount($piggybank->account); @@ -109,9 +109,13 @@ class PiggybankController extends BaseController /* * Flash some data to fill the form. */ - $prefilled = ['name' => $piggybank->name, 'account_id' => $piggybank->account_id, 'targetamount' => $piggybank->targetamount, - 'targetdate' => !is_null($piggybank->targetdate) ? $piggybank->targetdate->format('Y-m-d') : null, 'reminder' => $piggybank->reminder, - 'remind_me' => intval($piggybank->remind_me) == 1 ? true : false]; + $prefilled = ['name' => $piggybank->name, + 'account_id' => $piggybank->account_id, + 'targetamount' => $piggybank->targetamount, + 'targetdate' => !is_null($piggybank->targetdate) ? $piggybank->targetdate->format('Y-m-d') : null, + 'reminder' => $piggybank->reminder, + 'remind_me' => intval($piggybank->remind_me) == 1 || !is_null($piggybank->reminder) ? true : false + ]; Session::flash('prefilled', $prefilled); return View::make('piggybanks.edit', compact('piggybank', 'accounts', 'periods', 'prefilled'))->with('title', 'Piggybanks')->with( @@ -238,7 +242,7 @@ class PiggybankController extends BaseController */ $amountPerReminder = $piggybank->amountPerReminder(); - $remindersCount = $piggybank->countFutureReminders(); + $remindersCount = $piggybank->countFutureReminders(); return View::make('piggybanks.show', compact('amountPerReminder', 'remindersCount', 'piggybank', 'events'))->with('title', 'Piggy banks')->with( 'mainTitleIcon', 'fa-sort-amount-asc' diff --git a/app/lib/FireflyIII/Form/Form.php b/app/lib/FireflyIII/Form/Form.php index 82dee3b288..7f65078b33 100644 --- a/app/lib/FireflyIII/Form/Form.php +++ b/app/lib/FireflyIII/Form/Form.php @@ -51,7 +51,6 @@ class Form $options['autocomplete'] = 'off'; $label = self::label($name, $options); - /* * Make label and placeholder look nice. */ @@ -62,7 +61,8 @@ class Form */ if (\Session::has('prefilled')) { $prefilled = \Session::get('prefilled'); - $value = isset($prefilled[$name]) && is_null($value) ? $prefilled[$name] : $value; + //$value = isset($prefilled[$name]) && is_null($value) ? $prefilled[$name] : $value; + } /* @@ -132,7 +132,7 @@ class Form break; case 'checkbox': $checked = $options['checked']; - unset($options['checked'], $options['placeholder'], $options['autocomplete'], $options['class']); + unset($options['placeholder'], $options['autocomplete'], $options['class']); $html .= '
'; @@ -237,7 +237,7 @@ class Form */ public static function ffCheckbox($name, $value = 1, $checked = null, $options = []) { - $options['checked'] = $checked ? true : null; + $options['checked'] = $checked === true ? true : null; return self::ffInput('checkbox', $name, $value, $options); } diff --git a/app/lib/FireflyIII/Shared/Toolkit/Date.php b/app/lib/FireflyIII/Shared/Toolkit/Date.php index 6e01172b8f..d5018ebf53 100644 --- a/app/lib/FireflyIII/Shared/Toolkit/Date.php +++ b/app/lib/FireflyIII/Shared/Toolkit/Date.php @@ -69,6 +69,7 @@ class Date case 'daily': $currentEnd->addDay(); break; + case 'week': case 'weekly': $currentEnd->addWeek()->subDay(); break; @@ -105,6 +106,7 @@ class Date case 'daily': $date->startOfDay(); break; + case 'week': case 'weekly': $date->startOfWeek(); break; diff --git a/app/lib/FireflyIII/Shared/Toolkit/Reminders.php b/app/lib/FireflyIII/Shared/Toolkit/Reminders.php index 2e90acc006..263108ee37 100644 --- a/app/lib/FireflyIII/Shared/Toolkit/Reminders.php +++ b/app/lib/FireflyIII/Shared/Toolkit/Reminders.php @@ -3,6 +3,7 @@ namespace FireflyIII\Shared\Toolkit; use Carbon\Carbon; +use Illuminate\Support\Collection; /** * Class Reminders @@ -19,35 +20,24 @@ class Reminders public function getReminders() { return []; -// $reminders = \Auth::user()->reminders()->where('active', true)->get(); -// $return = []; -// /** @var \Reminder $reminder */ -// foreach ($reminders as $reminder) { -// $set = ['id' => $reminder->id]; -// switch ($reminder->data->type) { -// case 'Test': -// case 'Piggybank': -// $set['title'] = $reminder->title; -// $set['icon'] = $reminder->data->icon; -// $set['text'] = mf(floatval($reminder->data->amount)); -// break; -// -// } -// $return[] = $set; -// } -// -// return $return; - } - - public function updateReminders() - { -// $today = Carbon::now()->format('Y-m-d'); -// $reminders = \Auth::user()->reminders()->where('startdate', '<=', $today)->where('enddate', '>=', $today)->where('active', '=', 1)->get(); -// -// /* -// * Find all piggy banks in the current set of reminders. -// */ -// $this->updatePiggyBankReminders(); + // $reminders = \Auth::user()->reminders()->where('active', true)->get(); + // $return = []; + // /** @var \Reminder $reminder */ + // foreach ($reminders as $reminder) { + // $set = ['id' => $reminder->id]; + // switch ($reminder->data->type) { + // case 'Test': + // case 'Piggybank': + // $set['title'] = $reminder->title; + // $set['icon'] = $reminder->data->icon; + // $set['text'] = mf(floatval($reminder->data->amount)); + // break; + // + // } + // $return[] = $set; + // } + // + // return $return; } /** @@ -55,61 +45,114 @@ class Reminders */ public function updatePiggyBankReminders() { -// $piggyBanks = \Auth::user()->piggybanks()->where('targetdate', '>=', Carbon::now()->format('Y-m-d'))->whereNotNull('reminder')->where('remind_me', 1) -// ->get(); -// -// /** @var \FireflyIII\Shared\Toolkit\Date $dateKit */ -// $dateKit = \App::make('FireflyIII\Shared\Toolkit\Date'); -// -// $today = Carbon::now(); -// -// -// /** @var \Piggybank $piggyBank */ -// foreach ($piggyBanks as $piggyBank) { -// /* -// * Loop from today until end? -// */ -// $end = $piggyBank->targetdate; -// $start = Carbon::now(); -// -// /* -// * Create a reminder for the current period: -// */ -// /* -// * * type: Piggybank, Test -// * action_uri: where to go when the user wants to do this? -// * text: full text to present to user -// * amount: any relevant amount. -// * model: id of relevant model. -// */ -// -// while ($start <= $end) { -// $currentEnd = $dateKit->addPeriod(clone $start, $piggyBank->reminder, 0); -// -// $count = \Reminder::where('startdate',$start->format('Y-m-d'))->where('enddate',$currentEnd->format('Y-m-d'))->count(); -// if ($start >= $today && $start <= $today && $count == 0) { -// -// -// $reminder = new \Reminder; -// $reminder->active = 1; -// $reminder->user()->associate(\Auth::user()); -// $reminder->startdate = clone $start; -// $reminder->enddate = $currentEnd; -// $reminder->title = 'Add money to "'.e($piggyBank->name).'"'; -// $amount = $piggyBank->amountPerReminder(); -// $data = ['type' => 'Piggybank', 'icon' => 'fa-sort-amount-asc', 'text' => -// 'If you want to save up the full amount of "' . e($piggyBank->name) . '", add ' . mf($amount) . ' to account "' . e( -// $piggyBank->account->name -// ) . '". Don\'t forget to connect the transfer to this piggy bank!', 'amount' => $amount, 'model' => $piggyBank->id -// -// ]; -// $reminder->data = $data; -// $reminder->save(); -// } -// $start = $dateKit->addPeriod($start, $piggyBank->reminder, 0); -// } -// -// } + // $piggyBanks = \Auth::user()->piggybanks()->where('targetdate', '>=', Carbon::now()->format('Y-m-d'))->whereNotNull('reminder')->where('remind_me', 1) + // ->get(); + // + // /** @var \FireflyIII\Shared\Toolkit\Date $dateKit */ + // $dateKit = \App::make('FireflyIII\Shared\Toolkit\Date'); + // + // $today = Carbon::now(); + // + // + // /** @var \Piggybank $piggyBank */ + // foreach ($piggyBanks as $piggyBank) { + // /* + // * Loop from today until end? + // */ + // $end = $piggyBank->targetdate; + // $start = Carbon::now(); + // + // /* + // * Create a reminder for the current period: + // */ + // /* + // * * type: Piggybank, Test + // * action_uri: where to go when the user wants to do this? + // * text: full text to present to user + // * amount: any relevant amount. + // * model: id of relevant model. + // */ + // + // while ($start <= $end) { + // $currentEnd = $dateKit->addPeriod(clone $start, $piggyBank->reminder, 0); + // + // $count = \Reminder::where('startdate',$start->format('Y-m-d'))->where('enddate',$currentEnd->format('Y-m-d'))->count(); + // if ($start >= $today && $start <= $today && $count == 0) { + // + // + // $reminder = new \Reminder; + // $reminder->active = 1; + // $reminder->user()->associate(\Auth::user()); + // $reminder->startdate = clone $start; + // $reminder->enddate = $currentEnd; + // $reminder->title = 'Add money to "'.e($piggyBank->name).'"'; + // $amount = $piggyBank->amountPerReminder(); + // $data = ['type' => 'Piggybank', 'icon' => 'fa-sort-amount-asc', 'text' => + // 'If you want to save up the full amount of "' . e($piggyBank->name) . '", add ' . mf($amount) . ' to account "' . e( + // $piggyBank->account->name + // ) . '". Don\'t forget to connect the transfer to this piggy bank!', 'amount' => $amount, 'model' => $piggyBank->id + // + // ]; + // $reminder->data = $data; + // $reminder->save(); + // } + // $start = $dateKit->addPeriod($start, $piggyBank->reminder, 0); + // } + // + // } } + + public function updateReminders() + { + + /* + * Reminder capable objects are (so far) only piggy banks. + */ + /** @var \FireflyIII\Database\Piggybank $repository */ + $repository = \App::make('FireflyIII\Database\Piggybank'); + + /** @var \FireflyIII\Shared\Toolkit\Date $dateKit */ + $dateKit = \App::make('FireflyIII\Shared\Toolkit\Date'); + + + /** @var Collection $piggybanks */ + $piggybanks = $repository->get(); + $set = $piggybanks->filter( + function (\Piggybank $piggybank) { + if (!is_null($piggybank->reminder)) { + return $piggybank; + } + } + ); + + /** @var \Piggybank $piggybank */ + foreach ($set as $piggybank) { + /* + * Try to find a reminder that is valid in the current [period] + * aka between [start of period] and [end of period] as denoted + * by the piggy's repeat_freq. + */ + /** @var \PiggybankRepetition $repetition */ + $repetition = $piggybank->currentRelevantRep(); + $start = $dateKit->startOfPeriod(Carbon::now(), $piggybank->reminder); + if ($repetition->targetdate && $repetition->targetdate <= Carbon::now()) { + // break when no longer relevant: + continue; + } + $end = $dateKit->endOfPeriod(Carbon::now(), $piggybank->reminder); + // should have a reminder for this period: + /** @var \Collection $reminders */ + $reminders = $piggybank->reminders()->dateIs($start, $end)->get(); + if ($reminders->count() == 0) { + // create new! + $reminder = new \Reminder; + $reminder->startdate = $start; + $reminder->enddate = $end; + $reminder->user()->associate($repository->getUser()); + $reminder->remindersable()->associate($piggybank); + $reminder->save(); + } + } + } } \ No newline at end of file diff --git a/app/models/AccountType.php b/app/models/AccountType.php index 5a85adf626..1a3f910687 100644 --- a/app/models/AccountType.php +++ b/app/models/AccountType.php @@ -12,11 +12,11 @@ use Illuminate\Database\Eloquent\Model as Eloquent; * @property string $type * @property boolean $editable * @property-read \Illuminate\Database\Eloquent\Collection|\Account[] $accounts - * @method static \Illuminate\Database\Query\Builder|\AccountType whereId($value) - * @method static \Illuminate\Database\Query\Builder|\AccountType whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\AccountType whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\AccountType whereType($value) - * @method static \Illuminate\Database\Query\Builder|\AccountType whereEditable($value) + * @method static \Illuminate\Database\Query\Builder|\AccountType whereId($value) + * @method static \Illuminate\Database\Query\Builder|\AccountType whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\AccountType whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\AccountType whereType($value) + * @method static \Illuminate\Database\Query\Builder|\AccountType whereEditable($value) */ class AccountType extends Eloquent { diff --git a/app/models/Budget.php b/app/models/Budget.php index 59fb3a73f1..b5e516762c 100644 --- a/app/models/Budget.php +++ b/app/models/Budget.php @@ -13,12 +13,12 @@ * @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals * @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions * @property-read \User $user - * @method static \Illuminate\Database\Query\Builder|\Budget whereId($value) - * @method static \Illuminate\Database\Query\Builder|\Budget whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Budget whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Budget whereName($value) - * @method static \Illuminate\Database\Query\Builder|\Budget whereUserId($value) - * @method static \Illuminate\Database\Query\Builder|\Budget whereClass($value) + * @method static \Illuminate\Database\Query\Builder|\Budget whereId($value) + * @method static \Illuminate\Database\Query\Builder|\Budget whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Budget whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Budget whereName($value) + * @method static \Illuminate\Database\Query\Builder|\Budget whereUserId($value) + * @method static \Illuminate\Database\Query\Builder|\Budget whereClass($value) */ class Budget extends Component { diff --git a/app/models/Category.php b/app/models/Category.php index f8cda2fa37..c8258373d5 100644 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -14,12 +14,12 @@ * @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits * @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions * @property-read \User $user - * @method static \Illuminate\Database\Query\Builder|\Category whereId($value) - * @method static \Illuminate\Database\Query\Builder|\Category whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Category whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Category whereName($value) - * @method static \Illuminate\Database\Query\Builder|\Category whereUserId($value) - * @method static \Illuminate\Database\Query\Builder|\Category whereClass($value) + * @method static \Illuminate\Database\Query\Builder|\Category whereId($value) + * @method static \Illuminate\Database\Query\Builder|\Category whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Category whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Category whereName($value) + * @method static \Illuminate\Database\Query\Builder|\Category whereUserId($value) + * @method static \Illuminate\Database\Query\Builder|\Category whereClass($value) */ class Category extends Component { diff --git a/app/models/Limit.php b/app/models/Limit.php index 06c644e54b..bb9830d040 100644 --- a/app/models/Limit.php +++ b/app/models/Limit.php @@ -19,14 +19,14 @@ use LaravelBook\Ardent\Ardent as Ardent; * @property-read \Budget $budget * @property-read \Component $component * @property-read \Illuminate\Database\Eloquent\Collection|\LimitRepetition[] $limitrepetitions - * @method static \Illuminate\Database\Query\Builder|\Limit whereId($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereComponentId($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereStartdate($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereAmount($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereRepeats($value) - * @method static \Illuminate\Database\Query\Builder|\Limit whereRepeatFreq($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereId($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereComponentId($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereStartdate($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereAmount($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereRepeats($value) + * @method static \Illuminate\Database\Query\Builder|\Limit whereRepeatFreq($value) */ class Limit extends Ardent { diff --git a/app/models/LimitRepetition.php b/app/models/LimitRepetition.php index 61f89ce547..07effdb27f 100644 --- a/app/models/LimitRepetition.php +++ b/app/models/LimitRepetition.php @@ -15,13 +15,13 @@ use LaravelBook\Ardent\Ardent as Ardent; * @property \Carbon\Carbon $enddate * @property float $amount * @property-read \Limit $limit - * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereId($value) - * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereLimitId($value) - * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereStartdate($value) - * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereEnddate($value) - * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereAmount($value) + * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereId($value) + * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereLimitId($value) + * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereStartdate($value) + * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereEnddate($value) + * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereAmount($value) */ class LimitRepetition extends Ardent { diff --git a/app/models/Piggybank.php b/app/models/Piggybank.php index ff4adc609a..a0580c14c9 100644 --- a/app/models/Piggybank.php +++ b/app/models/Piggybank.php @@ -42,6 +42,7 @@ use LaravelBook\Ardent\Ardent as Ardent; * @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminderSkip($value) * @method static \Illuminate\Database\Query\Builder|\Piggybank whereOrder($value) * @method static \Illuminate\Database\Query\Builder|\Piggybank whereRemindMe($value) + * @property-read \Illuminate\Database\Eloquent\Collection|\Reminder[] $reminders */ class Piggybank extends Ardent { @@ -83,7 +84,7 @@ class Piggybank extends Ardent public function reminders() { - return $this->morphMany('Reminder', 'remembersable'); + return $this->morphMany('Reminder', 'remindersable'); } /** diff --git a/app/models/PiggybankEvent.php b/app/models/PiggybankEvent.php index d8edc9fa0c..be7b2fbcc2 100644 --- a/app/models/PiggybankEvent.php +++ b/app/models/PiggybankEvent.php @@ -15,13 +15,13 @@ use LaravelBook\Ardent\Ardent as Ardent; * @property integer $transaction_journal_id * @property-read \Piggybank $piggybank * @property-read \TransactionJournal $transactionJournal - * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereId($value) - * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent wherePiggybankId($value) - * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereDate($value) - * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereAmount($value) - * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereTransactionJournalId($value) + * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereId($value) + * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent wherePiggybankId($value) + * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereDate($value) + * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereAmount($value) + * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereTransactionJournalId($value) */ class PiggybankEvent extends Ardent { diff --git a/app/models/PiggybankRepetition.php b/app/models/PiggybankRepetition.php index a7c15705b0..3e4f2fa7fd 100644 --- a/app/models/PiggybankRepetition.php +++ b/app/models/PiggybankRepetition.php @@ -13,13 +13,13 @@ use LaravelBook\Ardent\Ardent as Ardent; * @property \Carbon\Carbon $targetdate * @property float $currentamount * @property-read \Piggybank $piggybank - * @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereId($value) - * @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition wherePiggybankId($value) - * @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 \Illuminate\Database\Query\Builder|\PiggybankRepetition whereId($value) + * @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition wherePiggybankId($value) + * @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) */ class PiggybankRepetition extends Ardent { diff --git a/app/models/Preference.php b/app/models/Preference.php index 151b169e1e..2638708714 100644 --- a/app/models/Preference.php +++ b/app/models/Preference.php @@ -13,12 +13,12 @@ use LaravelBook\Ardent\Ardent; * @property string $name * @property string $data * @property-read \User $user - * @method static \Illuminate\Database\Query\Builder|\Preference whereId($value) - * @method static \Illuminate\Database\Query\Builder|\Preference whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Preference whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Preference whereUserId($value) - * @method static \Illuminate\Database\Query\Builder|\Preference whereName($value) - * @method static \Illuminate\Database\Query\Builder|\Preference whereData($value) + * @method static \Illuminate\Database\Query\Builder|\Preference whereId($value) + * @method static \Illuminate\Database\Query\Builder|\Preference whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Preference whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Preference whereUserId($value) + * @method static \Illuminate\Database\Query\Builder|\Preference whereName($value) + * @method static \Illuminate\Database\Query\Builder|\Preference whereData($value) */ class Preference extends Ardent { diff --git a/app/models/RecurringTransaction.php b/app/models/RecurringTransaction.php index f5e9d98bc5..a1971644bb 100644 --- a/app/models/RecurringTransaction.php +++ b/app/models/RecurringTransaction.php @@ -21,19 +21,19 @@ use LaravelBook\Ardent\Ardent; * @property integer $skip * @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals * @property-read \User $user - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereId($value) - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereUserId($value) - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereName($value) - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereMatch($value) - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAmountMin($value) - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAmountMax($value) - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereDate($value) - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereActive($value) - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAutomatch($value) - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereRepeatFreq($value) - * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereSkip($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereId($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereUserId($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereName($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereMatch($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAmountMin($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAmountMax($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereDate($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereActive($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAutomatch($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereRepeatFreq($value) + * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereSkip($value) */ class RecurringTransaction extends Ardent { diff --git a/app/models/Reminder.php b/app/models/Reminder.php index 79c8aa8186..7742909eef 100644 --- a/app/models/Reminder.php +++ b/app/models/Reminder.php @@ -1,8 +1,35 @@ belongsTo('User'); } + public function scopeDateIs($query, Carbon $start, Carbon $end) + { + return $query->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d')); + } public function getDataAttribute($value) { diff --git a/app/models/Transaction.php b/app/models/Transaction.php index dcdf22871d..45cd458e26 100644 --- a/app/models/Transaction.php +++ b/app/models/Transaction.php @@ -22,20 +22,20 @@ use LaravelBook\Ardent\Builder; * @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components * @property-read \Piggybank $piggybank * @property-read \TransactionJournal $transactionJournal - * @method static \Illuminate\Database\Query\Builder|\Transaction whereId($value) - * @method static \Illuminate\Database\Query\Builder|\Transaction whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Transaction whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\Transaction whereAccountId($value) - * @method static \Illuminate\Database\Query\Builder|\Transaction wherePiggybankId($value) - * @method static \Illuminate\Database\Query\Builder|\Transaction whereTransactionJournalId($value) - * @method static \Illuminate\Database\Query\Builder|\Transaction whereDescription($value) - * @method static \Illuminate\Database\Query\Builder|\Transaction whereAmount($value) - * @method static \Transaction accountIs($account) - * @method static \Transaction after($date) - * @method static \Transaction before($date) - * @method static \Transaction lessThan($amount) - * @method static \Transaction moreThan($amount) - * @method static \Transaction transactionTypes($types) + * @method static \Illuminate\Database\Query\Builder|\Transaction whereId($value) + * @method static \Illuminate\Database\Query\Builder|\Transaction whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Transaction whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\Transaction whereAccountId($value) + * @method static \Illuminate\Database\Query\Builder|\Transaction wherePiggybankId($value) + * @method static \Illuminate\Database\Query\Builder|\Transaction whereTransactionJournalId($value) + * @method static \Illuminate\Database\Query\Builder|\Transaction whereDescription($value) + * @method static \Illuminate\Database\Query\Builder|\Transaction whereAmount($value) + * @method static \Transaction accountIs($account) + * @method static \Transaction after($date) + * @method static \Transaction before($date) + * @method static \Transaction lessThan($amount) + * @method static \Transaction moreThan($amount) + * @method static \Transaction transactionTypes($types) */ class Transaction extends Ardent { diff --git a/app/models/TransactionCurrency.php b/app/models/TransactionCurrency.php index 046a242def..8a8512f87f 100644 --- a/app/models/TransactionCurrency.php +++ b/app/models/TransactionCurrency.php @@ -10,10 +10,10 @@ use Illuminate\Database\Eloquent\Model as Eloquent; * @property \Carbon\Carbon $updated_at * @property string $code * @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals - * @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereId($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereCode($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereId($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereCode($value) */ class TransactionCurrency extends Eloquent { diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.php index 1651b4eecd..bae052d62e 100644 --- a/app/models/TransactionJournal.php +++ b/app/models/TransactionJournal.php @@ -29,25 +29,29 @@ use LaravelBook\Ardent\Builder; * @property-read \TransactionType $transactionType * @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions * @property-read \User $user - * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereId($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUserId($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereTransactionTypeId($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereRecurringTransactionId($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereTransactionCurrencyId($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDescription($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereCompleted($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDate($value) - * @method static \TransactionJournal accountIs($account) - * @method static \TransactionJournal after($date) - * @method static \TransactionJournal before($date) - * @method static \TransactionJournal defaultSorting() - * @method static \TransactionJournal lessThan($amount) - * @method static \TransactionJournal moreThan($amount) - * @method static \TransactionJournal onDate($date) - * @method static \TransactionJournal transactionTypes($types) - * @method static \TransactionJournal withRelevantData() + * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereId($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUserId($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereTransactionTypeId($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereRecurringTransactionId($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereTransactionCurrencyId($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDescription($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereCompleted($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDate($value) + * @method static \TransactionJournal accountIs($account) + * @method static \TransactionJournal after($date) + * @method static \TransactionJournal before($date) + * @method static \TransactionJournal defaultSorting() + * @method static \TransactionJournal lessThan($amount) + * @method static \TransactionJournal moreThan($amount) + * @method static \TransactionJournal onDate($date) + * @method static \TransactionJournal transactionTypes($types) + * @method static \TransactionJournal withRelevantData() + * @property-read \Illuminate\Database\Eloquent\Collection|\ + * 'Budget[] $budgets + * @property-read \Illuminate\Database\Eloquent\Collection|\ + * 'Category[] $categories */ class TransactionJournal extends Ardent { diff --git a/app/models/TransactionType.php b/app/models/TransactionType.php index 9633bc07e1..348e0ceef9 100644 --- a/app/models/TransactionType.php +++ b/app/models/TransactionType.php @@ -10,10 +10,10 @@ use LaravelBook\Ardent\Ardent; * @property \Carbon\Carbon $updated_at * @property string $type * @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionJournals - * @method static \Illuminate\Database\Query\Builder|\TransactionType whereId($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionType whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionType whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\TransactionType whereType($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionType whereId($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionType whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionType whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\TransactionType whereType($value) */ class TransactionType extends Ardent { diff --git a/app/models/User.php b/app/models/User.php index 88b46873c4..a4ec72a7fd 100644 --- a/app/models/User.php +++ b/app/models/User.php @@ -24,14 +24,14 @@ use LaravelBook\Ardent\Ardent; * @property-read \Illuminate\Database\Eloquent\Collection|\Preference[] $preferences * @property-read \Illuminate\Database\Eloquent\Collection|\RecurringTransaction[] $recurringtransactions * @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals - * @method static \Illuminate\Database\Query\Builder|\User whereId($value) - * @method static \Illuminate\Database\Query\Builder|\User whereCreatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\User whereUpdatedAt($value) - * @method static \Illuminate\Database\Query\Builder|\User whereEmail($value) - * @method static \Illuminate\Database\Query\Builder|\User wherePassword($value) - * @method static \Illuminate\Database\Query\Builder|\User whereReset($value) - * @method static \Illuminate\Database\Query\Builder|\User whereRememberToken($value) - * @method static \Illuminate\Database\Query\Builder|\User whereMigrated($value) + * @method static \Illuminate\Database\Query\Builder|\User whereId($value) + * @method static \Illuminate\Database\Query\Builder|\User whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\User whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\User whereEmail($value) + * @method static \Illuminate\Database\Query\Builder|\User wherePassword($value) + * @method static \Illuminate\Database\Query\Builder|\User whereReset($value) + * @method static \Illuminate\Database\Query\Builder|\User whereRememberToken($value) + * @method static \Illuminate\Database\Query\Builder|\User whereMigrated($value) */ class User extends Ardent implements UserInterface, RemindableInterface {