diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index cfd7a7c7e2..2251706607 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -26,9 +26,11 @@ use Carbon\Carbon; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Helpers\Collector\TransactionCollectorInterface; use FireflyIII\Http\Requests\BillFormRequest; +use FireflyIII\Models\Attachment; use FireflyIII\Models\Bill; use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\TransactionRules\TransactionMatcher; +use FireflyIII\Transformers\AttachmentTransformer; use FireflyIII\Transformers\BillTransformer; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; @@ -315,8 +317,21 @@ class BillController extends Controller $transactions = $collector->getPaginatedTransactions(); $transactions->setPath(route('bills.show', [$bill->id])); + // transform any attachments as well. + $collection = $this->billRepository->getAttachments($bill); + $attachments = new Collection; + if ($collection->count() > 0) { + /** @var AttachmentTransformer $transformer */ + $transformer = app(AttachmentTransformer::class); + $attachments = $collection->each( + function (Attachment $attachment) use ($transformer) { + return $transformer->transform($attachment); + } + ); + } - return view('bills.show', compact('transactions', 'rules', 'yearAverage', 'overallAverage', 'year', 'object', 'bill', 'subTitle')); + + return view('bills.show', compact('attachments', 'transactions', 'rules', 'yearAverage', 'overallAverage', 'year', 'object', 'bill', 'subTitle')); } diff --git a/resources/views/v1/bills/show.twig b/resources/views/v1/bills/show.twig index 0510ecdbf5..26afa17311 100644 --- a/resources/views/v1/bills/show.twig +++ b/resources/views/v1/bills/show.twig @@ -102,14 +102,15 @@ {% endif %} - {% if object.data.attachments_count > 0 %} + + {% if attachments.count > 0 %}

{{ 'attachments'|_ }}

- {% for att in object.data.attachments.data %} + {% for att in attachments %}