This commit is contained in:
James Cole 2019-01-27 16:42:28 +01:00
parent eeff2895aa
commit 7e1d430003
2 changed files with 19 additions and 3 deletions

View File

@ -26,9 +26,11 @@ use Carbon\Carbon;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface; use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Http\Requests\BillFormRequest; use FireflyIII\Http\Requests\BillFormRequest;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Bill; use FireflyIII\Models\Bill;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\TransactionRules\TransactionMatcher; use FireflyIII\TransactionRules\TransactionMatcher;
use FireflyIII\Transformers\AttachmentTransformer;
use FireflyIII\Transformers\BillTransformer; use FireflyIII\Transformers\BillTransformer;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -315,8 +317,21 @@ class BillController extends Controller
$transactions = $collector->getPaginatedTransactions(); $transactions = $collector->getPaginatedTransactions();
$transactions->setPath(route('bills.show', [$bill->id])); $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'));
} }

View File

@ -102,14 +102,15 @@
</div> </div>
{% endif %} {% endif %}
{% if object.data.attachments_count > 0 %}
{% if attachments.count > 0 %}
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">{{ 'attachments'|_ }}</h3> <h3 class="box-title">{{ 'attachments'|_ }}</h3>
</div> </div>
<div class="box-body table-responsive no-padding"> <div class="box-body table-responsive no-padding">
<table class="table table-hover"> <table class="table table-hover">
{% for att in object.data.attachments.data %} {% for att in attachments %}
<tr> <tr>
<td> <td>
<div class="btn-group btn-group-xs"> <div class="btn-group btn-group-xs">