From c0d715c78abf836ad33e18f76638efc245e96ee8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 29 Apr 2018 07:46:03 +0200 Subject: [PATCH] Add method to collect note text. --- app/Repositories/Bill/BillRepository.php | 20 ++++++++++++++++++- .../Bill/BillRepositoryInterface.php | 10 +++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index a78481ddfb..a9c1e38be2 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -26,6 +26,7 @@ use Carbon\Carbon; use DB; use FireflyIII\Factory\BillFactory; use FireflyIII\Models\Bill; +use FireflyIII\Models\Note; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; @@ -242,6 +243,24 @@ class BillRepository implements BillRepositoryInterface return $sum; } + /** + * Get text or return empty string. + * + * @param Bill $bill + * + * @return string + */ + public function getNoteText(Bill $bill): string + { + /** @var Note $note */ + $note = $bill->notes()->first(); + if (null !== $note) { + return (string)$note->text; + } + + return ''; + } + /** * @param Bill $bill * @@ -554,5 +573,4 @@ class BillRepository implements BillRepositoryInterface return $service->update($bill, $data); } - } diff --git a/app/Repositories/Bill/BillRepositoryInterface.php b/app/Repositories/Bill/BillRepositoryInterface.php index c53c8aa6e3..37f7e6abd7 100644 --- a/app/Repositories/Bill/BillRepositoryInterface.php +++ b/app/Repositories/Bill/BillRepositoryInterface.php @@ -24,7 +24,6 @@ namespace FireflyIII\Repositories\Bill; use Carbon\Carbon; use FireflyIII\Models\Bill; -use FireflyIII\Models\TransactionJournal; use FireflyIII\User; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Collection; @@ -99,6 +98,15 @@ interface BillRepositoryInterface */ public function getBillsUnpaidInRange(Carbon $start, Carbon $end): string; + /** + * Get text or return empty string. + * + * @param Bill $bill + * + * @return string + */ + public function getNoteText(Bill $bill): string; + /** * @param Bill $bill *