Implemented a proper way of generating reminders (we hope).

This commit is contained in:
James Cole 2014-11-17 22:32:55 +01:00
parent 4f4e6fac16
commit 9918410954
20 changed files with 294 additions and 209 deletions

View File

@ -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'

View File

@ -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 .= '<div class="checkbox"><label>';
$html .= \Form::checkbox($name, $value, $checked, $options);
$html .= '</label></div>';
@ -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);
}

View File

@ -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;

View File

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

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

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

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -1,8 +1,35 @@
<?php
use Carbon\Carbon;
use LaravelBook\Ardent\Ardent;
class Reminder extends 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 integer $remembersable_id
* @property string $remembersable_type
* @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 whereRemembersableId($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereRemembersableType($value)
* @method static \Reminder dateIs($start, $end)
*/
class Reminder extends Eloquent
{
protected $table = 'reminders';
@ -35,6 +62,10 @@ class Reminder extends Ardent
{
return $this->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)
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{