Some improved sorting.

This commit is contained in:
James Cole 2015-07-08 13:11:51 +02:00
parent 6900392e43
commit c9fff197f7
4 changed files with 31 additions and 5 deletions

View File

@ -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;

View File

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

View File

@ -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);
}
);

View File

@ -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);
}
);