Expand search

This commit is contained in:
James Cole
2022-03-20 17:11:33 +01:00
parent ba10aa5ca5
commit 02687dfe53
17 changed files with 827 additions and 388 deletions

View File

@@ -32,33 +32,20 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
*/
trait CollectorProperties
{
/** @var array The standard fields to select. */
private $fields;
/** @var bool Will be set to true if query result contains account information. (see function withAccountInformation). */
private $hasAccountInfo;
/** @var bool Will be true if query result includes bill information. */
private $hasBillInformation;
/** @var bool Will be true if query result contains budget info. */
private $hasBudgetInformation;
/** @var bool Will be true if query result contains category info. */
private $hasCatInformation;
/** @var bool Will be true for attachments */
private $hasJoinedAttTables;
private array $fields;
private bool $hasAccountInfo;
private bool $hasBillInformation;
private bool $hasBudgetInformation;
private bool $hasCatInformation;
private bool $hasJoinedAttTables;
private bool $hasJoinedMetaTables;
/** @var bool Will be true of the query has the tag info tables joined. */
private $hasJoinedTagTables;
/** @var bool */
private $hasNotesInformation;
/** @var array */
private $integerFields;
/** @var int The maximum number of results. */
private $limit;
/** @var int The page to return. */
private $page;
/** @var HasMany The query object. */
private $query;
/** @var int Total number of results. */
private $total;
/** @var User The user object. */
private $user;
private bool $hasJoinedTagTables;
private bool $hasNotesInformation;
private array $integerFields;
private ?int $limit;
private ?int $page;
private HasMany $query;
private int $total;
private ?User $user;
private array $postFilters;
}

View File

@@ -32,6 +32,7 @@ use FireflyIII\Models\Tag;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use Log;
/**
* Trait MetaCollection
@@ -295,6 +296,35 @@ trait MetaCollection
return $this;
}
/**
* Without tags
*
* @param Collection $tags
*
* @return GroupCollectorInterface
*/
public function setWithoutSpecificTags(Collection $tags): GroupCollectorInterface
{
$this->withTagInformation();
// this method adds a "postFilter" to the collector.
$list = $tags->pluck('tag')->toArray();
$filter = function (int $index, array $object) use ($list): bool {
foreach($object['transactions'] as $transaction) {
foreach($transaction['tags'] as $tag) {
if(in_array($tag['name'], $list)) {
return false;
}
}
}
return true;
};
$this->postFilters[] = $filter;
return $this;
}
/**
* @return GroupCollectorInterface
*/
@@ -307,7 +337,7 @@ trait MetaCollection
}
/**
* Limit results to transactions without a bill..
* Limit results to transactions without a bill.
*
* @return GroupCollectorInterface
*/