mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Expand API, add new migration.
This commit is contained in:
@@ -190,7 +190,10 @@ class BillRepository implements BillRepositoryInterface
|
||||
public function getBills(): Collection
|
||||
{
|
||||
/** @var Collection $set */
|
||||
return $this->user->bills()->orderBy('active', 'DESC')->orderBy('name', 'ASC')->get();
|
||||
return $this->user->bills()
|
||||
->orderBy('order', 'ASC')
|
||||
->orderBy('active', 'DESC')
|
||||
->orderBy('name', 'ASC')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -711,4 +714,20 @@ class BillRepository implements BillRepositoryInterface
|
||||
{
|
||||
$this->user->transactionJournals()->where('bill_id', $bill->id)->update(['bill_id' => null]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct order of piggies in case of issues.
|
||||
*/
|
||||
public function correctOrder(): void
|
||||
{
|
||||
$set = $this->user->bills()->orderBy('order', 'ASC')->get();
|
||||
$current = 1;
|
||||
foreach ($set as $bill) {
|
||||
if ((int) $bill->order !== $current) {
|
||||
$bill->order = $current;
|
||||
$bill->save();
|
||||
}
|
||||
$current++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user