mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix various code.
This commit is contained in:
@@ -29,6 +29,8 @@ use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
use function Safe\json_encode;
|
||||
|
||||
/**
|
||||
* Class AccountSearch
|
||||
*/
|
||||
@@ -81,7 +83,7 @@ class AccountSearch implements GenericSearchInterface
|
||||
// meta data:
|
||||
$searchQuery->orWhere(
|
||||
static function (Builder $q) use ($originalQuery): void {
|
||||
$json = \Safe\json_encode($originalQuery, JSON_THROW_ON_ERROR);
|
||||
$json = json_encode($originalQuery, JSON_THROW_ON_ERROR);
|
||||
$q->where('account_meta.name', '=', 'account_number');
|
||||
$q->whereLike('account_meta.data', $json);
|
||||
}
|
||||
@@ -108,7 +110,7 @@ class AccountSearch implements GenericSearchInterface
|
||||
// meta data:
|
||||
$searchQuery->Where(
|
||||
static function (Builder $q) use ($originalQuery): void {
|
||||
$json = \Safe\json_encode($originalQuery, JSON_THROW_ON_ERROR);
|
||||
$json = json_encode($originalQuery, JSON_THROW_ON_ERROR);
|
||||
$q->where('account_meta.name', 'account_number');
|
||||
$q->where('account_meta.data', $json);
|
||||
}
|
||||
|
@@ -719,10 +719,10 @@ class OperatorQuerySearch implements SearchInterface
|
||||
//
|
||||
case 'currency_is':
|
||||
$currency = $this->findCurrency($value);
|
||||
if (null !== $currency) {
|
||||
if ($currency instanceof TransactionCurrency) {
|
||||
$this->collector->setCurrency($currency);
|
||||
}
|
||||
if (null === $currency) {
|
||||
if (!$currency instanceof TransactionCurrency) {
|
||||
$this->collector->findNothing();
|
||||
}
|
||||
|
||||
@@ -730,10 +730,10 @@ class OperatorQuerySearch implements SearchInterface
|
||||
|
||||
case '-currency_is':
|
||||
$currency = $this->findCurrency($value);
|
||||
if (null !== $currency) {
|
||||
if ($currency instanceof TransactionCurrency) {
|
||||
$this->collector->excludeCurrency($currency);
|
||||
}
|
||||
if (null === $currency) {
|
||||
if (!$currency instanceof TransactionCurrency) {
|
||||
$this->collector->findNothing();
|
||||
}
|
||||
|
||||
@@ -741,10 +741,10 @@ class OperatorQuerySearch implements SearchInterface
|
||||
|
||||
case 'foreign_currency_is':
|
||||
$currency = $this->findCurrency($value);
|
||||
if (null !== $currency) {
|
||||
if ($currency instanceof TransactionCurrency) {
|
||||
$this->collector->setForeignCurrency($currency);
|
||||
}
|
||||
if (null === $currency) {
|
||||
if (!$currency instanceof TransactionCurrency) {
|
||||
$this->collector->findNothing();
|
||||
}
|
||||
|
||||
@@ -752,10 +752,10 @@ class OperatorQuerySearch implements SearchInterface
|
||||
|
||||
case '-foreign_currency_is':
|
||||
$currency = $this->findCurrency($value);
|
||||
if (null !== $currency) {
|
||||
if ($currency instanceof TransactionCurrency) {
|
||||
$this->collector->excludeForeignCurrency($currency);
|
||||
}
|
||||
if (null === $currency) {
|
||||
if (!$currency instanceof TransactionCurrency) {
|
||||
$this->collector->findNothing();
|
||||
}
|
||||
|
||||
@@ -2109,7 +2109,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
}
|
||||
$result = $this->currencyRepository->findByCode($value);
|
||||
if (null === $result) {
|
||||
$result = $this->currencyRepository->findByName($value);
|
||||
return $this->currencyRepository->findByName($value);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@@ -33,6 +33,8 @@ use Illuminate\Support\Facades\Log;
|
||||
use LogicException;
|
||||
use TypeError;
|
||||
|
||||
use function Safe\fwrite;
|
||||
|
||||
class GdbotsQueryParser implements QueryParserInterface
|
||||
{
|
||||
private readonly BaseQueryParser $parser;
|
||||
@@ -56,7 +58,7 @@ class GdbotsQueryParser implements QueryParserInterface
|
||||
|
||||
return new NodeGroup($nodes);
|
||||
} catch (LogicException|TypeError $e) {
|
||||
\Safe\fwrite(STDERR, "Setting up GdbotsQueryParserTest\n");
|
||||
fwrite(STDERR, "Setting up GdbotsQueryParserTest\n");
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error(sprintf('Could not parse search: "%s".', $query));
|
||||
|
||||
|
@@ -51,7 +51,7 @@ class QueryParser implements QueryParserInterface
|
||||
$nodes = [];
|
||||
$nodeResult = $this->buildNextNode($isSubquery);
|
||||
|
||||
while (null !== $nodeResult->node) {
|
||||
while ($nodeResult->node instanceof Node) {
|
||||
$nodes[] = $nodeResult->node;
|
||||
if ($nodeResult->isSubqueryEnd) {
|
||||
break;
|
||||
|
Reference in New Issue
Block a user