From c9fff197f7ac7e7ca619cd340f3ab0051358a199 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 8 Jul 2015 13:11:51 +0200 Subject: [PATCH] Some improved sorting. --- app/Http/Controllers/TagController.php | 10 +++++++++ app/Repositories/Budget/BudgetRepository.php | 22 ++++++++++++++++--- .../Category/CategoryRepository.php | 2 +- app/Repositories/Tag/TagRepository.php | 2 +- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 80a680c9ba..1f28df89b2 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -8,6 +8,7 @@ use FireflyIII\Http\Requests\TagFormRequest; use FireflyIII\Models\Preference; use FireflyIII\Models\Tag; use FireflyIII\Repositories\Tag\TagRepositoryInterface; +use Illuminate\Support\Collection; use Input; use Preferences; use Response; @@ -184,7 +185,16 @@ class TagController extends Controller // loop each types and get the tags, group them by year. $collection = []; foreach ($types as $type) { + + /** @var Collection $tags */ $tags = Auth::user()->tags()->where('tagMode', $type)->orderBy('date', 'ASC')->get(); + + $tags = $tags->sortBy( + function (Tag $tag) { + return strtolower($tag->tag); + } + ); + /** @var Tag $tag */ foreach ($tags as $tag) { $year = is_null($tag->date) ? trans('firefly.no_year') : $tag->date->year; diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index 1b8dd99b93..18b3d2d064 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -62,9 +62,16 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn */ public function getActiveBudgets() { - $budgets = Auth::user()->budgets()->where('active', 1)->get(); + /** @var Collection $set */ + $set = Auth::user()->budgets()->where('active', 1)->get(); - return $budgets; + $set = $set->sortBy( + function (Budget $budget) { + return strtolower($budget->name); + } + ); + + return $set; } /** @@ -146,7 +153,16 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn */ public function getInactiveBudgets() { - return Auth::user()->budgets()->where('active', 0)->get(); + /** @var Collection $set */ + $set = Auth::user()->budgets()->where('active', 0)->get(); + + $set = $set->sortBy( + function (Budget $budget) { + return strtolower($budget->name); + } + ); + + return $set; } /** diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index d23a30bf2c..0cd96d8038 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -50,7 +50,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito $set = Auth::user()->categories()->orderBy('name', 'ASC')->get(); $set = $set->sortBy( function (Category $category) { - return $category->name; + return strtolower($category->name); } ); diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index 7353dd1210..1d8f848f51 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -112,7 +112,7 @@ class TagRepository implements TagRepositoryInterface $tags = Auth::user()->tags()->get(); $tags = $tags->sortBy( function (Tag $tag) { - return $tag->tag; + return strtolower($tag->tag); } );