mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Extend API
This commit is contained in:
@@ -39,6 +39,32 @@ class BillRepository implements BillRepositoryInterface
|
||||
{
|
||||
use AdministrationTrait;
|
||||
|
||||
/**
|
||||
* Correct order of piggies in case of issues.
|
||||
*/
|
||||
public function correctOrder(): void
|
||||
{
|
||||
$set = $this->userGroup->bills()->orderBy('order', 'ASC')->get();
|
||||
$current = 1;
|
||||
foreach ($set as $bill) {
|
||||
if ((int)$bill->order !== $current) {
|
||||
$bill->order = $current;
|
||||
$bill->save();
|
||||
}
|
||||
$current++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBills(): Collection
|
||||
{
|
||||
return $this->userGroup->bills()
|
||||
->orderBy('bills.name', 'ASC')
|
||||
->get(['bills.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -109,7 +135,6 @@ class BillRepository implements BillRepositoryInterface
|
||||
->get(['bills.*']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
||||
@@ -32,11 +32,22 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface BillRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* TODO duplicate of other repos
|
||||
* Add correct order to bills.
|
||||
*/
|
||||
public function correctOrder(): void;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getActiveBills(): Collection;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBills(): Collection;
|
||||
|
||||
/**
|
||||
* Between start and end, tells you on which date(s) the bill is expected to hit.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user