This commit is contained in:
James Cole
2023-12-21 05:07:26 +01:00
parent 1f7ceb6df6
commit a445bc53cd
61 changed files with 165 additions and 163 deletions

View File

@@ -104,7 +104,7 @@ class AccountRepository implements AccountRepositoryInterface
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('accounts.active', true)
->where(
static function (EloquentBuilder $q1) use ($number) { // @phpstan-ignore-line
static function (EloquentBuilder $q1) use ($number): void { // @phpstan-ignore-line
$json = json_encode($number);
$q1->where('account_meta.name', '=', 'account_number');
$q1->where('account_meta.data', '=', $json);
@@ -184,7 +184,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$query = $this->user->accounts()->with(
[
'accountmeta' => static function (HasMany $query) {
'accountmeta' => static function (HasMany $query): void {
$query->where('name', 'account_role');
},
'attachments',
@@ -257,7 +257,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$query = $this->user->accounts()->with(
[
'accountmeta' => static function (HasMany $query) {
'accountmeta' => static function (HasMany $query): void {
$query->where('name', 'account_role');
},
]
@@ -597,10 +597,10 @@ class AccountRepository implements AccountRepositoryInterface
foreach ($parts as $part) {
$search = sprintf('%%%s%%', $part);
$dbQuery->where(
static function (EloquentBuilder $q1) use ($search) { // @phpstan-ignore-line
static function (EloquentBuilder $q1) use ($search): void { // @phpstan-ignore-line
$q1->where('accounts.iban', 'LIKE', $search);
$q1->orWhere(
static function (EloquentBuilder $q2) use ($search) {
static function (EloquentBuilder $q2) use ($search): void {
$q2->where('account_meta.name', '=', 'account_number');
$q2->where('account_meta.data', 'LIKE', $search);
}

View File

@@ -203,13 +203,13 @@ class BillRepository implements BillRepositoryInterface
return $this->user->bills()
->leftJoin(
'transaction_journals',
static function (JoinClause $join) {
static function (JoinClause $join): void {
$join->on('transaction_journals.bill_id', '=', 'bills.id')->whereNull('transaction_journals.deleted_at');
}
)
->leftJoin(
'transactions',
static function (JoinClause $join) {
static function (JoinClause $join): void {
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '<', 0);
}
)

View File

@@ -64,7 +64,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
$query = $this->user->availableBudgets()->with(['transactionCurrency']);
if (null !== $start && null !== $end) {
$query->where(
static function (Builder $q1) use ($start, $end) { // @phpstan-ignore-line
static function (Builder $q1) use ($start, $end): void { // @phpstan-ignore-line
$q1->where('start_date', '=', $start->format('Y-m-d'));
$q1->where('end_date', '=', $end->format('Y-m-d'));
}

View File

@@ -51,17 +51,17 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
// same complex where query as below.
->where(
static function (Builder $q5) use ($start, $end) {
static function (Builder $q5) use ($start, $end): void {
$q5->where(
static function (Builder $q1) use ($start, $end) {
static function (Builder $q1) use ($start, $end): void {
$q1->where(
static function (Builder $q2) use ($start, $end) {
static function (Builder $q2) use ($start, $end): void {
$q2->where('budget_limits.end_date', '>=', $start->format('Y-m-d'));
$q2->where('budget_limits.end_date', '<=', $end->format('Y-m-d'));
}
)
->orWhere(
static function (Builder $q3) use ($start, $end) {
static function (Builder $q3) use ($start, $end): void {
$q3->where('budget_limits.start_date', '>=', $start->format('Y-m-d'));
$q3->where('budget_limits.start_date', '<=', $end->format('Y-m-d'));
}
@@ -70,7 +70,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
}
)
->orWhere(
static function (Builder $q4) use ($start, $end) {
static function (Builder $q4) use ($start, $end): void {
// or start is before start AND end is after end.
$q4->where('budget_limits.start_date', '<=', $start->format('Y-m-d'));
$q4->where('budget_limits.end_date', '>=', $end->format('Y-m-d'));
@@ -165,17 +165,17 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
->where('budgets.user_id', $this->user->id)
->whereNull('budgets.deleted_at')
->where(
static function (Builder $q5) use ($start, $end) {
static function (Builder $q5) use ($start, $end): void {
$q5->where(
static function (Builder $q1) use ($start, $end) {
static function (Builder $q1) use ($start, $end): void {
$q1->where(
static function (Builder $q2) use ($start, $end) {
static function (Builder $q2) use ($start, $end): void {
$q2->where('budget_limits.end_date', '>=', $start->format('Y-m-d'));
$q2->where('budget_limits.end_date', '<=', $end->format('Y-m-d'));
}
)
->orWhere(
static function (Builder $q3) use ($start, $end) {
static function (Builder $q3) use ($start, $end): void {
$q3->where('budget_limits.start_date', '>=', $start->format('Y-m-d'));
$q3->where('budget_limits.start_date', '<=', $end->format('Y-m-d'));
}
@@ -184,7 +184,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
}
)
->orWhere(
static function (Builder $q4) use ($start, $end) {
static function (Builder $q4) use ($start, $end): void {
// or start is before start AND end is after end.
$q4->where('budget_limits.start_date', '<=', $start->format('Y-m-d'));
$q4->where('budget_limits.end_date', '>=', $end->format('Y-m-d'));
@@ -219,19 +219,19 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
// when both dates are set:
return $budget->budgetlimits()
->where(
static function (Builder $q5) use ($start, $end) { // @phpstan-ignore-line
static function (Builder $q5) use ($start, $end): void { // @phpstan-ignore-line
$q5->where(
static function (Builder $q1) use ($start, $end) {
static function (Builder $q1) use ($start, $end): void {
// budget limit ends within period
$q1->where(
static function (Builder $q2) use ($start, $end) {
static function (Builder $q2) use ($start, $end): void {
$q2->where('budget_limits.end_date', '>=', $start->format('Y-m-d 00:00:00'));
$q2->where('budget_limits.end_date', '<=', $end->format('Y-m-d 23:59:59'));
}
)
// budget limit start within period
->orWhere(
static function (Builder $q3) use ($start, $end) {
static function (Builder $q3) use ($start, $end): void {
$q3->where('budget_limits.start_date', '>=', $start->format('Y-m-d 00:00:00'));
$q3->where('budget_limits.start_date', '<=', $end->format('Y-m-d 23:59:59'));
}
@@ -240,7 +240,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
}
)
->orWhere(
static function (Builder $q4) use ($start, $end) {
static function (Builder $q4) use ($start, $end): void {
// or start is before start AND end is after end.
$q4->where('budget_limits.start_date', '<=', $start->format('Y-m-d 23:59:59'));
$q4->where('budget_limits.end_date', '>=', $end->format('Y-m-d 00:00:00'));

View File

@@ -87,7 +87,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
{
$events = $journal->piggyBankEvents()->get();
$events->each(
static function (PiggyBankEvent $event) {
static function (PiggyBankEvent $event): void {
$event->piggyBank = $event->piggyBank()->withTrashed()->first();
}
);

View File

@@ -64,14 +64,14 @@ class RecurringRepository implements RecurringRepositoryInterface
{
// if not, loop set and try to read the recurrence_date. If it matches start or end, return it as well.
$set
= TransactionJournalMeta::where(static function (Builder $q1) use ($recurrence) {
= TransactionJournalMeta::where(static function (Builder $q1) use ($recurrence): void {
$q1->where('name', 'recurrence_id');
$q1->where('data', json_encode((string)$recurrence->id));
})->get(['journal_meta.transaction_journal_id']);
// there are X journals made for this recurrence. Any of them meant for today?
foreach ($set as $journalMeta) {
$count = TransactionJournalMeta::where(static function (Builder $q2) use ($date) {
$count = TransactionJournalMeta::where(static function (Builder $q2) use ($date): void {
$string = (string)$date;
app('log')->debug(sprintf('Search for date: %s', json_encode($string)));
$q2->where('name', 'recurrence_date');

View File

@@ -212,13 +212,13 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
->orderBy('order', 'ASC')
->with(
[
'rules' => static function (HasMany $query) {
'rules' => static function (HasMany $query): void {
$query->orderBy('order', 'ASC');
},
'rules.ruleTriggers' => static function (HasMany $query) {
'rules.ruleTriggers' => static function (HasMany $query): void {
$query->orderBy('order', 'ASC');
},
'rules.ruleActions' => static function (HasMany $query) {
'rules.ruleActions' => static function (HasMany $query): void {
$query->orderBy('order', 'ASC');
},
]
@@ -268,13 +268,13 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
->where('active', true)
->with(
[
'rules' => static function (HasMany $query) {
'rules' => static function (HasMany $query): void {
$query->orderBy('order', 'ASC');
},
'rules.ruleTriggers' => static function (HasMany $query) {
'rules.ruleTriggers' => static function (HasMany $query): void {
$query->orderBy('order', 'ASC');
},
'rules.ruleActions' => static function (HasMany $query) {
'rules.ruleActions' => static function (HasMany $query): void {
$query->orderBy('order', 'ASC');
},
]

View File

@@ -121,7 +121,7 @@ class TagRepository implements TagRepositoryInterface
$disk = \Storage::disk('upload');
return $set->each(
static function (Attachment $attachment) use ($disk) {
static function (Attachment $attachment) use ($disk): void {
/** @var null|Note $note */
$note = $attachment->notes()->first();
// only used in v1 view of tags

View File

@@ -153,7 +153,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
$return = [];
$journals = $group->transactionJournals->pluck('id')->toArray();
$set = TransactionJournalLink::where(
static function (Builder $q) use ($journals) {
static function (Builder $q) use ($journals): void {
$q->whereIn('source_id', $journals);
$q->orWhereIn('destination_id', $journals);
}

View File

@@ -46,7 +46,7 @@ class AccountRepository implements AccountRepositoryInterface
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('accounts.active', true)
->where(
static function (EloquentBuilder $q1) use ($number) { // @phpstan-ignore-line
static function (EloquentBuilder $q1) use ($number): void { // @phpstan-ignore-line
$json = json_encode($number);
$q1->where('account_meta.name', '=', 'account_number');
$q1->where('account_meta.data', '=', $json);