mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-26 05:26:17 +00:00
Code reordering and reformatting. I should really start employing style CI.
This commit is contained in:
@@ -69,9 +69,9 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
|
||||
|
||||
return $set->each(
|
||||
static function (Attachment $attachment) use ($disk) {
|
||||
$notes = $attachment->notes()->first();
|
||||
$notes = $attachment->notes()->first();
|
||||
$attachment->file_exists = $disk->exists($attachment->fileName());
|
||||
$attachment->notes = $notes ? $notes->text : '';
|
||||
$attachment->notes = $notes ? $notes->text : '';
|
||||
|
||||
return $attachment;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use JsonException;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
@@ -117,7 +118,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
* @param string $field
|
||||
*
|
||||
* @return null|Carbon
|
||||
* @throws \JsonException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function getMetaDate(TransactionJournal $journal, string $field): ?Carbon
|
||||
{
|
||||
@@ -129,7 +130,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
if ($cache->has()) {
|
||||
$result = null;
|
||||
try {
|
||||
$result = new Carbon($cache->get());
|
||||
$result = new Carbon($cache->get());
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
// @ignoreException
|
||||
}
|
||||
@@ -161,7 +162,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
* @param string $field
|
||||
*
|
||||
* @return null|string
|
||||
* @throws \JsonException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function getMetaField(TransactionJournal $journal, string $field): ?string
|
||||
{
|
||||
@@ -171,7 +172,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
$cache->addProperty($field);
|
||||
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
return $cache->get();
|
||||
}
|
||||
|
||||
$entry = $journal->transactionJournalMeta()->where('name', $field)->first();
|
||||
|
||||
@@ -37,6 +37,7 @@ use FireflyIII\Services\Internal\Update\JournalUpdateService;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* Class JournalRepository.
|
||||
@@ -68,18 +69,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$service->destroy($journal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function findByType(array $types): Collection
|
||||
{
|
||||
return $this->user
|
||||
->transactionJournals()
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->whereIn('transaction_types.type', $types)
|
||||
->get(['transaction_journals.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a specific journal.
|
||||
*
|
||||
@@ -92,6 +81,18 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $this->user->transactionJournals()->find($journalId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function findByType(array $types): Collection
|
||||
{
|
||||
return $this->user
|
||||
->transactionJournals()
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->whereIn('transaction_types.type', $types)
|
||||
->get(['transaction_journals.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get users first transaction journal or NULL.
|
||||
*
|
||||
@@ -129,7 +130,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return string
|
||||
* @throws \JsonException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function getJournalTotal(TransactionJournal $journal): string
|
||||
{
|
||||
@@ -137,7 +138,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('amount-positive');
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
return $cache->get();
|
||||
}
|
||||
|
||||
// saves on queries:
|
||||
@@ -186,7 +187,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
* @param string $field
|
||||
*
|
||||
* @return null|Carbon
|
||||
* @throws \JsonException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function getMetaDateById(int $journalId, string $field): ?Carbon
|
||||
{
|
||||
@@ -196,7 +197,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$cache->addProperty($field);
|
||||
|
||||
if ($cache->has()) {
|
||||
return new Carbon($cache->get());
|
||||
return new Carbon($cache->get());
|
||||
}
|
||||
$entry = TransactionJournalMeta::where('transaction_journal_id', $journalId)
|
||||
->where('name', $field)->first();
|
||||
|
||||
@@ -50,13 +50,6 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
public function destroyJournal(TransactionJournal $journal): void;
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function findByType(array $types): Collection;
|
||||
|
||||
/**
|
||||
* See reference nr. 1
|
||||
* Find a specific journal.
|
||||
@@ -67,6 +60,13 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
public function find(int $journalId): ?TransactionJournal;
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function findByType(array $types): Collection;
|
||||
|
||||
/**
|
||||
* Get users very first transaction journal.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user