mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Order categories by name.
This commit is contained in:
@@ -46,7 +46,15 @@ class CategoryRepository implements CategoryRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getCategories()
|
public function getCategories()
|
||||||
{
|
{
|
||||||
return Auth::user()->categories()->orderBy('name', 'ASC')->get();
|
/** @var Collection $set */
|
||||||
|
$set = Auth::user()->categories()->orderBy('name', 'ASC')->get();
|
||||||
|
$set->sortBy(
|
||||||
|
function (Category $category) {
|
||||||
|
return $category->name;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return $set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -167,6 +175,17 @@ class CategoryRepository implements CategoryRepositoryInterface
|
|||||||
return floatval($category->transactionjournals()->before($end)->after($start)->lessThan(0)->sum('amount')) * -1;
|
return floatval($category->transactionjournals()->before($end)->after($start)->lessThan(0)->sum('amount')) * -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Category $category
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public function spentOnDaySum(Category $category, Carbon $date)
|
||||||
|
{
|
||||||
|
return floatval($category->transactionjournals()->onDate($date)->lessThan(0)->sum('amount')) * -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
@@ -199,15 +218,4 @@ class CategoryRepository implements CategoryRepositoryInterface
|
|||||||
|
|
||||||
return $category;
|
return $category;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Category $category
|
|
||||||
* @param Carbon $date
|
|
||||||
*
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function spentOnDaySum(Category $category, Carbon $date)
|
|
||||||
{
|
|
||||||
return floatval($category->transactionjournals()->onDate($date)->lessThan(0)->sum('amount')) * -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user