Various code cleanup

This commit is contained in:
James Cole
2022-12-31 15:54:55 +01:00
parent 7722ca2bf0
commit 4d0ff86bfa
4 changed files with 12 additions and 7 deletions

View File

@@ -54,6 +54,8 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
}
/**
* TODO pretty sure method duplicated.
*
* Return all attachments for journal.
*
* @param TransactionJournal $journal
@@ -71,7 +73,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
$attachment->notes = $notes ? $notes->text : '';
$attachment->notes = $notes ? $notes->text : ''; // TODO should not set notes like this.
return $attachment;
}

View File

@@ -95,7 +95,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
*/
public function find(int $piggyBankId): ?PiggyBank
{
return $this->user->piggyBanks()->find($piggyBankId);
// phpstan doesn't get the Model.
return $this->user->piggyBanks()->find($piggyBankId); // @phpstan-ignore-line
}
/**
@@ -124,7 +125,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
$attachment->notes = $notes ? $notes->text : '';
$attachment->notes = $notes ? $notes->text : ''; // TODO setting the text to the 'notes' field doesn't work.
return $attachment;
}
@@ -331,11 +332,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
*/
public function getPiggyBanks(): Collection
{
return $this->user
return $this->user // @phpstan-ignore-line (phpstan does not recognize objectGroups)
->piggyBanks()
->with(
['account',
'objectGroups']) // @phpstan-ignore-line (phpstan does not recognize objectGroups)
'objectGroups'])
->orderBy('order', 'ASC')->get();
}