Extend API

This commit is contained in:
James Cole
2023-08-09 14:14:33 +02:00
parent 03f39f53d8
commit a2984f299b
13 changed files with 95 additions and 34 deletions

View File

@@ -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
*/

View File

@@ -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.
*