mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Updated models [skip ci]
This commit is contained in:
parent
0b2d423c87
commit
65ce277a20
@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Account
|
* Class Account
|
||||||
@ -64,10 +66,10 @@ class Account extends Eloquent
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param Builder $query
|
* @param EloquentBuilder $query
|
||||||
* @param array $types
|
* @param array $types
|
||||||
*/
|
*/
|
||||||
public function scopeAccountTypeIn(Builder $query, array $types)
|
public function scopeAccountTypeIn(EloquentBuilder $query, array $types)
|
||||||
{
|
{
|
||||||
if (is_null($this->joinedAccountTypes)) {
|
if (is_null($this->joinedAccountTypes)) {
|
||||||
$query->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id');
|
$query->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id');
|
||||||
@ -78,9 +80,9 @@ class Account extends Eloquent
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param Builder $query
|
* @param EloquentBuilder $query
|
||||||
*/
|
*/
|
||||||
public function scopeWithMeta(Builder $query)
|
public function scopeWithMeta(EloquentBuilder $query)
|
||||||
{
|
{
|
||||||
$query->with(['accountmeta']);
|
$query->with(['accountmeta']);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ use Carbon\Carbon;
|
|||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PiggyBank
|
* Class PiggyBank
|
||||||
@ -73,24 +73,23 @@ class PiggyBank extends Eloquent
|
|||||||
if ($this->repeats == 0) {
|
if ($this->repeats == 0) {
|
||||||
$rep = $this->piggyBankRepetitions()->first(['piggy_bank_repetitions.*']);
|
$rep = $this->piggyBankRepetitions()->first(['piggy_bank_repetitions.*']);
|
||||||
$this->currentRep = $rep;
|
$this->currentRep = $rep;
|
||||||
\Log::debug('currentRelevantRep() reports $rep is null: ' . boolstr(is_null($rep)));
|
|
||||||
|
|
||||||
return $rep;
|
return $rep;
|
||||||
} else {
|
} else {
|
||||||
$query = $this->piggyBankRepetitions()->where(
|
$query = $this->piggyBankRepetitions()->where(
|
||||||
function (Builder $q) {
|
function (EloquentBuilder $q) {
|
||||||
|
|
||||||
$q->where(
|
$q->where(
|
||||||
function (Builder $q) {
|
function (EloquentBuilder $q) {
|
||||||
|
|
||||||
$q->where(
|
$q->where(
|
||||||
function (Builder $q) {
|
function (EloquentBuilder $q) {
|
||||||
$today = new Carbon;
|
$today = new Carbon;
|
||||||
$q->whereNull('startdate');
|
$q->whereNull('startdate');
|
||||||
$q->orWhere('startdate', '<=', $today->format('Y-m-d 00:00:00'));
|
$q->orWhere('startdate', '<=', $today->format('Y-m-d 00:00:00'));
|
||||||
}
|
}
|
||||||
)->where(
|
)->where(
|
||||||
function (Builder $q) {
|
function (EloquentBuilder $q) {
|
||||||
$today = new Carbon;
|
$today = new Carbon;
|
||||||
$q->whereNull('targetdate');
|
$q->whereNull('targetdate');
|
||||||
$q->orWhere('targetdate', '>=', $today->format('Y-m-d 00:00:00'));
|
$q->orWhere('targetdate', '>=', $today->format('Y-m-d 00:00:00'));
|
||||||
@ -98,7 +97,7 @@ class PiggyBank extends Eloquent
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
)->orWhere(
|
)->orWhere(
|
||||||
function (Builder $q) {
|
function (EloquentBuilder $q) {
|
||||||
$today = new Carbon;
|
$today = new Carbon;
|
||||||
$q->where('startdate', '>=', $today->format('Y-m-d 00:00:00'));
|
$q->where('startdate', '>=', $today->format('Y-m-d 00:00:00'));
|
||||||
$q->where('targetdate', '>=', $today->format('Y-m-d 00:00:00'));
|
$q->where('targetdate', '>=', $today->format('Y-m-d 00:00:00'));
|
||||||
@ -108,7 +107,6 @@ class PiggyBank extends Eloquent
|
|||||||
}
|
}
|
||||||
)->orderBy('startdate', 'ASC');
|
)->orderBy('startdate', 'ASC');
|
||||||
$result = $query->first(['piggy_bank_repetitions.*']);
|
$result = $query->first(['piggy_bank_repetitions.*']);
|
||||||
\Log::debug('Result is null: ' . boolstr(is_null($result)));
|
|
||||||
$this->currentRep = $result;
|
$this->currentRep = $result;
|
||||||
\Log::debug('Found relevant rep in currentRelevantRep(): ' . $result->id);
|
\Log::debug('Found relevant rep in currentRelevantRep(): ' . $result->id);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
@ -33,19 +33,19 @@ class PiggyBankRepetition extends Eloquent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Builder $query
|
* @param EloquentBuilder $query
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
*/
|
*/
|
||||||
public function scopeStarts(Builder $query, Carbon $date)
|
public function scopeStarts(EloquentBuilder $query, Carbon $date)
|
||||||
{
|
{
|
||||||
$query->where('startdate', $date->format('Y-m-d 00:00:00'));
|
$query->where('startdate', $date->format('Y-m-d 00:00:00'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Builder $query
|
* @param EloquentBuilder $query
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
*/
|
*/
|
||||||
public function scopeTargets(Builder $query, Carbon $date)
|
public function scopeTargets(EloquentBuilder $query, Carbon $date)
|
||||||
{
|
{
|
||||||
$query->where('targetdate', $date->format('Y-m-d 00:00:00'));
|
$query->where('targetdate', $date->format('Y-m-d 00:00:00'));
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Query\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TransactionJournal
|
* Class TransactionJournal
|
||||||
@ -94,7 +94,7 @@ class TransactionJournal extends Eloquent
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*/
|
*/
|
||||||
public function scopeAccountIs(Builder $query, \Account $account)
|
public function scopeAccountIs($query, \Account $account)
|
||||||
{
|
{
|
||||||
if (!isset($this->joinedTransactions)) {
|
if (!isset($this->joinedTransactions)) {
|
||||||
$query->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id');
|
$query->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id');
|
||||||
@ -129,7 +129,7 @@ class TransactionJournal extends Eloquent
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @param $amount
|
* @param $amount
|
||||||
*/
|
*/
|
||||||
public function scopeLessThan(Builder $query, $amount)
|
public function scopeLessThan($query, $amount)
|
||||||
{
|
{
|
||||||
if (is_null($this->joinedTransactions)) {
|
if (is_null($this->joinedTransactions)) {
|
||||||
$query->leftJoin(
|
$query->leftJoin(
|
||||||
@ -145,7 +145,7 @@ class TransactionJournal extends Eloquent
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @param $amount
|
* @param $amount
|
||||||
*/
|
*/
|
||||||
public function scopeMoreThan(Builder $query, $amount)
|
public function scopeMoreThan($query, $amount)
|
||||||
{
|
{
|
||||||
if (is_null($this->joinedTransactions)) {
|
if (is_null($this->joinedTransactions)) {
|
||||||
$query->leftJoin(
|
$query->leftJoin(
|
||||||
@ -172,7 +172,7 @@ class TransactionJournal extends Eloquent
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @param array $types
|
* @param array $types
|
||||||
*/
|
*/
|
||||||
public function scopeTransactionTypes(Builder $query, array $types)
|
public function scopeTransactionTypes($query, array $types)
|
||||||
{
|
{
|
||||||
if (is_null($this->joinedTransactionTypes)) {
|
if (is_null($this->joinedTransactionTypes)) {
|
||||||
$query->leftJoin(
|
$query->leftJoin(
|
||||||
@ -189,10 +189,10 @@ class TransactionJournal extends Eloquent
|
|||||||
*
|
*
|
||||||
* @param $query
|
* @param $query
|
||||||
*/
|
*/
|
||||||
public function scopeWithRelevantData(Builder $query)
|
public function scopeWithRelevantData($query)
|
||||||
{
|
{
|
||||||
$query->with(
|
$query->with(
|
||||||
['transactions' => function (Builder $q) {
|
['transactions' => function (HasMany $q) {
|
||||||
$q->orderBy('amount', 'ASC');
|
$q->orderBy('amount', 'ASC');
|
||||||
}, 'transactiontype', 'budgets','categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories']
|
}, 'transactiontype', 'budgets','categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories']
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user