James Cole 2022-02-17 19:22:58 +01:00
parent 280762fff3
commit ec93b7b5a0
No known key found for this signature in database
GPG Key ID: BDE6667570EADBD5

View File

@ -481,6 +481,7 @@ class GroupCollector implements GroupCollectorInterface
public function withAttachmentInformation(): GroupCollectorInterface public function withAttachmentInformation(): GroupCollectorInterface
{ {
$this->fields[] = 'attachments.id as attachment_id'; $this->fields[] = 'attachments.id as attachment_id';
$this->fields[] = 'attachments.uploaded as attachment_uploaded';
$this->joinAttachmentTables(); $this->joinAttachmentTables();
return $this; return $this;
@ -498,7 +499,7 @@ class GroupCollector implements GroupCollectorInterface
->where( ->where(
static function (EloquentBuilder $q1) { static function (EloquentBuilder $q1) {
$q1->where('attachments.attachable_type', TransactionJournal::class); $q1->where('attachments.attachable_type', TransactionJournal::class);
$q1->where('attachments.uploaded', true); //$q1->where('attachments.uploaded', true);
$q1->orWhereNull('attachments.attachable_type'); $q1->orWhereNull('attachments.attachable_type');
} }
); );
@ -594,7 +595,8 @@ class GroupCollector implements GroupCollectorInterface
{ {
$newArray = $newJournal->toArray(); $newArray = $newJournal->toArray();
if (array_key_exists('attachment_id', $newArray)) { if (array_key_exists('attachment_id', $newArray)) {
$attachmentId = (int)$newJournal['tag_id']; $attachmentId = (int) $newJournal['attachment_id'];
$existingJournal['attachments'][$attachmentId] = [ $existingJournal['attachments'][$attachmentId] = [
'id' => $attachmentId, 'id' => $attachmentId,
]; ];
@ -728,8 +730,9 @@ class GroupCollector implements GroupCollectorInterface
// also merge attachments: // also merge attachments:
if (array_key_exists('attachment_id', $result)) { if (array_key_exists('attachment_id', $result)) {
$uploaded = 1 === (int)$result['attachment_uploaded'];
$attachmentId = (int) $augumentedJournal['attachment_id']; $attachmentId = (int) $augumentedJournal['attachment_id'];
if (0 !== $attachmentId) { if (0 !== $attachmentId && $uploaded) {
$result['attachments'][$attachmentId] = [ $result['attachments'][$attachmentId] = [
'id' => $attachmentId, 'id' => $attachmentId,
]; ];