mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-06 12:45:30 +00:00
Remove various sort routines.
This commit is contained in:
@@ -103,16 +103,7 @@ class Bill
|
||||
*/
|
||||
public function getBills(): Collection
|
||||
{
|
||||
$set = $this->bills->sortBy(
|
||||
function (BillLine $bill) {
|
||||
$active = 0 === (int)$bill->getBill()->active ? 1 : 0;
|
||||
$name = $bill->getBill()->name;
|
||||
|
||||
return $active . $name;
|
||||
}
|
||||
);
|
||||
|
||||
return $set;
|
||||
return $this->bills;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -144,11 +144,6 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
||||
$set->push($budget);
|
||||
}
|
||||
}
|
||||
$set = $set->sortBy(
|
||||
function (Budget $budget) {
|
||||
return $budget->name;
|
||||
}
|
||||
);
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
@@ -77,15 +77,6 @@ class IndexController extends Controller
|
||||
$types = config('firefly.accountTypesByIdentifier.' . $what);
|
||||
$collection = $this->repository->getAccountsByType($types);
|
||||
$total = $collection->count();
|
||||
|
||||
// sort collection:
|
||||
$collection = $collection->sortBy(
|
||||
function (Account $account) {
|
||||
return ($account->active ? '0' : '1') . $account->name;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||
|
@@ -212,11 +212,6 @@ class BillController extends Controller
|
||||
return $return;
|
||||
}
|
||||
);
|
||||
$bills = $bills->sortBy(
|
||||
function (array $bill) {
|
||||
return (int)!$bill['active'] . strtolower($bill['name']);
|
||||
}
|
||||
);
|
||||
|
||||
// add info about rules:
|
||||
$rules = $this->billRepository->getRulesForBills($paginator->getCollection());
|
||||
|
@@ -114,6 +114,7 @@ class BillController extends Controller
|
||||
}
|
||||
|
||||
$results = $collector->setAllAssetAccounts()->setBills(new Collection([$bill]))->getTransactions();
|
||||
// TODO remove me
|
||||
/** @var Collection $results */
|
||||
$results = $results->sortBy(
|
||||
function (Transaction $transaction) {
|
||||
|
@@ -311,13 +311,6 @@ class CurrencyController extends Controller
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$collection = $this->repository->getAll();
|
||||
$total = $collection->count();
|
||||
$collection = $collection->sortBy(
|
||||
function (TransactionCurrency $currency) {
|
||||
$intEnabled = $currency->enabled ? 0 : 1;
|
||||
|
||||
return $intEnabled . $currency->name;
|
||||
}
|
||||
);
|
||||
$collection = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||
$currencies = new LengthAwarePaginator($collection, $total, $pageSize, $page);
|
||||
$currencies->setPath(route('currencies.index'));
|
||||
|
@@ -25,12 +25,21 @@ namespace FireflyIII\Http\Controllers\Json;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Http\Controllers\AutoCompleteCollector;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class AutoCompleteController.
|
||||
@@ -41,6 +50,51 @@ class AutoCompleteController extends Controller
|
||||
{
|
||||
use AutoCompleteCollector;
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function accounts(Request $request): JsonResponse
|
||||
{
|
||||
$accountTypes = explode(',', $request->get('types') ?? '');
|
||||
$search = $request->get('query');
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
|
||||
// filter the account types:
|
||||
$allowedAccountTypes = [AccountType::ASSET, AccountType::EXPENSE, AccountType::REVENUE, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,];
|
||||
$filteredAccountTypes = [];
|
||||
foreach ($accountTypes as $type) {
|
||||
if (in_array($type, $allowedAccountTypes, true)) {
|
||||
$filteredAccountTypes[] = $type;
|
||||
}
|
||||
}
|
||||
Log::debug('Now in accounts(). Filtering results.', $filteredAccountTypes);
|
||||
|
||||
$return = [];
|
||||
$result = $repository->searchAccount((string)$search, $filteredAccountTypes);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($result as $account) {
|
||||
$currency = $repository->getAccountCurrency($account);
|
||||
$currency = $currency ?? $defaultCurrency;
|
||||
$return[] = [
|
||||
'id' => $account->id,
|
||||
'name' => $account->name,
|
||||
'type' => $account->accountType->type,
|
||||
'currency_id' => $currency->id,
|
||||
'currency_name' => $currency->name,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_decimal_places' => $currency->decimal_places,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
return response()->json($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* List of all journals.
|
||||
*
|
||||
@@ -84,8 +138,8 @@ class AutoCompleteController extends Controller
|
||||
* @param Request $request
|
||||
* @param string $subject
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function autoComplete(Request $request, string $subject): JsonResponse
|
||||
{
|
||||
@@ -140,6 +194,59 @@ class AutoCompleteController extends Controller
|
||||
return response()->json($filtered);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function budgets(): JsonResponse
|
||||
{
|
||||
/** @var BudgetRepositoryInterface $repository */
|
||||
$repository = app(BudgetRepositoryInterface::class);
|
||||
|
||||
return response()->json($repository->getActiveBudgets()->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function categories(Request $request): JsonResponse
|
||||
{
|
||||
$query = (string)$request->get('query');
|
||||
/** @var CategoryRepositoryInterface $repository */
|
||||
$repository = app(CategoryRepositoryInterface::class);
|
||||
$result = $repository->searchCategory($query);
|
||||
|
||||
return response()->json($result->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function currencies(Request $request): JsonResponse
|
||||
{
|
||||
/** @var CurrencyRepositoryInterface $repository */
|
||||
$repository = app(CurrencyRepositoryInterface::class);
|
||||
$return = [];
|
||||
$collection = $repository->getAll();
|
||||
|
||||
/** @var TransactionCurrency $currency */
|
||||
foreach ($collection as $currency) {
|
||||
$return[] = [
|
||||
'id' => $currency->id,
|
||||
'name' => $currency->name,
|
||||
'code' => $currency->code,
|
||||
'symbol' => $currency->symbol,
|
||||
'enabled' => $currency->enabled,
|
||||
'decimal_places' => $currency->decimal_places,
|
||||
];
|
||||
}
|
||||
|
||||
return response()->json($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* List of journals with their ID.
|
||||
*
|
||||
@@ -192,6 +299,31 @@ class AutoCompleteController extends Controller
|
||||
return response()->json($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function piggyBanks(): JsonResponse
|
||||
{
|
||||
/** @var PiggyBankRepositoryInterface $repository */
|
||||
$repository = app(PiggyBankRepositoryInterface::class);
|
||||
|
||||
return response()->json($repository->getPiggyBanks()->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function tags(Request $request): JsonResponse
|
||||
{
|
||||
$query = (string)$request->get('query');
|
||||
/** @var TagRepositoryInterface $repository */
|
||||
$repository = app(TagRepositoryInterface::class);
|
||||
$result = $repository->searchTags($query);
|
||||
|
||||
|
||||
return response()->json($result->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* List of journals by type.
|
||||
*
|
||||
|
@@ -25,11 +25,67 @@ namespace FireflyIII\Http\Controllers\Transaction;
|
||||
|
||||
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Class CreateController
|
||||
*/
|
||||
class CreateController extends Controller
|
||||
{
|
||||
/**
|
||||
* CreateController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$maxFileSize = app('steam')->phpBytes(ini_get('upload_max_filesize'));
|
||||
$maxPostSize = app('steam')->phpBytes(ini_get('post_max_size'));
|
||||
$uploadSize = min($maxFileSize, $maxPostSize);
|
||||
app('view')->share('uploadSize', $uploadSize);
|
||||
$this->middleware(
|
||||
static function ($request, $next) {
|
||||
|
||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||
app('view')->share('mainTitleIcon', 'fa-repeat');
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new transaction group.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string|null objectType
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function create(Request $request, string $objectType = null)
|
||||
{
|
||||
$objectType = strtolower($objectType ?? TransactionType::WITHDRAWAL);
|
||||
$preFilled = session()->has('preFilled') ? session('preFilled') : [];
|
||||
$subTitle = (string)trans('breadcrumbs.create_new_transaction');
|
||||
$subTitleIcon = 'fa-plus';
|
||||
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
|
||||
$source = (int)$request->get('source');
|
||||
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
|
||||
$accountToTypes = config('firefly.account_to_transaction');
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
session()->put('preFilled', $preFilled);
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (true !== session('transactions.create.fromStore')) {
|
||||
$this->rememberPreviousUri('transactions.create.uri');
|
||||
}
|
||||
session()->forget('transactions.create.fromStore');
|
||||
|
||||
return view(
|
||||
'transactions.create',
|
||||
compact('subTitleIcon', 'objectType', 'subTitle', 'defaultCurrency', 'optionalFields', 'preFilled', 'allowedOpposingTypes', 'accountToTypes')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@@ -54,7 +54,7 @@ class SecureHeaders
|
||||
sprintf("script-src 'self' 'unsafe-eval' 'unsafe-inline' %s", $google),
|
||||
"style-src 'self' 'unsafe-inline'",
|
||||
"base-uri 'self'",
|
||||
"font-src 'self'",
|
||||
"font-src 'self' data:",
|
||||
"connect-src 'self'",
|
||||
"img-src 'self' data: https://api.tiles.mapbox.com",
|
||||
"manifest-src 'self'",
|
||||
|
@@ -226,17 +226,12 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
/** @var Collection $result */
|
||||
$query = $this->user->accounts();
|
||||
|
||||
if (\count($accountIds) > 0) {
|
||||
if (count($accountIds) > 0) {
|
||||
$query->whereIn('accounts.id', $accountIds);
|
||||
}
|
||||
$query->orderBy('accounts.name','ASC');
|
||||
|
||||
$result = $query->get(['accounts.*']);
|
||||
$result = $result->sortBy(
|
||||
function (Account $account) {
|
||||
return strtolower($account->name);
|
||||
}
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -252,13 +247,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
if (\count($types) > 0) {
|
||||
$query->accountTypeIn($types);
|
||||
}
|
||||
|
||||
$query->orderBy('accounts.name','ASC');
|
||||
$result = $query->get(['accounts.*']);
|
||||
$result = $result->sortBy(
|
||||
function (Account $account) {
|
||||
return strtolower($account->name);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -280,12 +271,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$query->accountTypeIn($types);
|
||||
}
|
||||
$query->where('active', 1);
|
||||
$query->orderBy('accounts.account_type_id','ASC');
|
||||
$query->orderBy('accounts.name','ASC');
|
||||
$result = $query->get(['accounts.*']);
|
||||
$result = $result->sortBy(
|
||||
function (Account $account) {
|
||||
return sprintf('%02d', $account->account_type_id) . strtolower($account->name);
|
||||
}
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -564,13 +552,15 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*/
|
||||
public function searchAccount(string $query, array $types): Collection
|
||||
{
|
||||
$dbQuery = $this->user->accounts();
|
||||
$dbQuery = $this->user->accounts()->with(['accountType']);
|
||||
if ('' !== $query) {
|
||||
$search = sprintf('%%%s%%', $query);
|
||||
if (\count($types) > 0) {
|
||||
$dbQuery->where('name', 'LIKE', $search);
|
||||
}
|
||||
if (count($types) > 0) {
|
||||
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||
$dbQuery->whereIn('account_types.type', $types);
|
||||
}
|
||||
$dbQuery->where('name', 'LIKE', $search);
|
||||
|
||||
return $dbQuery->get(['accounts.*']);
|
||||
}
|
||||
|
@@ -146,8 +146,8 @@ class BillRepository implements BillRepositoryInterface
|
||||
/** @var Collection $set */
|
||||
$set = $this->user->bills()
|
||||
->where('active', 1)
|
||||
->get(['bills.*', DB::raw('((bills.amount_min + bills.amount_max) / 2) AS expectedAmount'),])
|
||||
->sortBy('name');
|
||||
->orderBy('bills.name', 'ASC')
|
||||
->get(['bills.*', DB::raw('((bills.amount_min + bills.amount_max) / 2) AS expectedAmount'),]);
|
||||
|
||||
return $set;
|
||||
}
|
||||
@@ -170,15 +170,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
public function getBills(): Collection
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = $this->user->bills()->orderBy('name', 'ASC')->get();
|
||||
|
||||
$set = $set->sortBy(
|
||||
function (Bill $bill) {
|
||||
$int = $bill->active ? 0 : 1;
|
||||
|
||||
return $int . strtolower($bill->name);
|
||||
}
|
||||
);
|
||||
$set = $this->user->bills()->orderBy('active', 'DESC')->orderBy('name', 'ASC')->get();
|
||||
|
||||
return $set;
|
||||
}
|
||||
@@ -210,17 +202,11 @@ class BillRepository implements BillRepositoryInterface
|
||||
)
|
||||
->whereIn('transactions.account_id', $ids)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->orderBy('bills.active', 'DESC')
|
||||
->orderBy('bills.name', 'ASC')
|
||||
->groupBy($fields)
|
||||
->get($fields);
|
||||
|
||||
$set = $set->sortBy(
|
||||
function (Bill $bill) {
|
||||
$int = $bill->active ? 0 : 1;
|
||||
|
||||
return $int . strtolower($bill->name);
|
||||
}
|
||||
);
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
|
@@ -312,16 +312,10 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = $this->user->budgets()->where('active', 1)
|
||||
->orderBy('order','DESC')
|
||||
->orderBy('name', 'ASC')
|
||||
->get();
|
||||
|
||||
$set = $set->sortBy(
|
||||
function (Budget $budget) {
|
||||
$str = str_pad((string)$budget->order, 4, '0', STR_PAD_LEFT) . strtolower($budget->name);
|
||||
|
||||
return $str;
|
||||
}
|
||||
);
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
@@ -596,15 +590,8 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
public function getBudgets(): Collection
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = $this->user->budgets()->get();
|
||||
|
||||
$set = $set->sortBy(
|
||||
function (Budget $budget) {
|
||||
$str = str_pad((string)$budget->order, 4, '0', STR_PAD_LEFT) . strtolower($budget->name);
|
||||
|
||||
return $str;
|
||||
}
|
||||
);
|
||||
$set = $this->user->budgets()->orderBy('order','DESC')
|
||||
->orderBy('name', 'ASC')->get();
|
||||
|
||||
return $set;
|
||||
}
|
||||
@@ -629,15 +616,8 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
public function getInactiveBudgets(): Collection
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = $this->user->budgets()->where('active', 0)->get();
|
||||
|
||||
$set = $set->sortBy(
|
||||
function (Budget $budget) {
|
||||
$str = str_pad((string)$budget->order, 4, '0', STR_PAD_LEFT) . strtolower($budget->name);
|
||||
|
||||
return $str;
|
||||
}
|
||||
);
|
||||
$set = $this->user->budgets()->orderBy('order','DESC')
|
||||
->orderBy('name', 'ASC')->where('active', 0)->get();
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
@@ -344,11 +344,6 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = $this->user->categories()->orderBy('name', 'ASC')->get();
|
||||
$set = $set->sortBy(
|
||||
function (Category $category) {
|
||||
return strtolower($category->name);
|
||||
}
|
||||
);
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
@@ -117,15 +117,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
*/
|
||||
public function findByTag(string $tag): ?Tag
|
||||
{
|
||||
$tags = $this->user->tags()->get();
|
||||
/** @var Tag $databaseTag */
|
||||
foreach ($tags as $databaseTag) {
|
||||
if ($databaseTag->tag === $tag) {
|
||||
return $databaseTag;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return $this->user->tags()->where('tag', $tag)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,12 +151,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
public function get(): Collection
|
||||
{
|
||||
/** @var Collection $tags */
|
||||
$tags = $this->user->tags()->get();
|
||||
$tags = $tags->sortBy(
|
||||
function (Tag $tag) {
|
||||
return strtolower($tag->tag);
|
||||
}
|
||||
);
|
||||
$tags = $this->user->tags()->orderBy('tag', 'ASC')->get();
|
||||
|
||||
return $tags;
|
||||
}
|
||||
@@ -219,6 +206,25 @@ class TagRepository implements TagRepositoryInterface
|
||||
return $this->user->tags()->whereNotNull('date')->orderBy('date', 'ASC')->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the users tags.
|
||||
*
|
||||
* @param string $query
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchTags(string $query): Collection
|
||||
{
|
||||
/** @var Collection $tags */
|
||||
$tags = $this->user->tags()->orderBy('tag', 'ASC');
|
||||
if ('' !== $query) {
|
||||
$search = sprintf('%%%s%%', $query);
|
||||
$tags->where('tag', 'LIKE', $search);
|
||||
}
|
||||
|
||||
return $tags->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
|
@@ -122,6 +122,15 @@ interface TagRepositoryInterface
|
||||
*/
|
||||
public function oldestTag(): ?Tag;
|
||||
|
||||
/**
|
||||
* Search the users tags.
|
||||
*
|
||||
* @param string $query
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchTags(string $query): Collection;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
|
@@ -22,7 +22,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -52,6 +51,7 @@ class AccountList implements BinderInterface
|
||||
$collection = auth()->user()->accounts()
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->where('account_types.type', AccountType::ASSET)
|
||||
->orderBy('accounts.name', 'ASC')
|
||||
->get(['accounts.*']);
|
||||
}
|
||||
if ('allAssetAccounts' !== $value) {
|
||||
@@ -61,16 +61,11 @@ class AccountList implements BinderInterface
|
||||
$collection = auth()->user()->accounts()
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->whereIn('accounts.id', $list)
|
||||
->orderBy('accounts.name', 'ASC')
|
||||
->get(['accounts.*']);
|
||||
}
|
||||
|
||||
if ($collection->count() > 0) {
|
||||
$collection = $collection->sortBy(
|
||||
function (Account $account) {
|
||||
return $account->name;
|
||||
}
|
||||
);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
|
@@ -394,11 +394,7 @@ trait RenderPartialViews
|
||||
{
|
||||
/** @var TagRepositoryInterface $repository */
|
||||
$repository = app(TagRepositoryInterface::class);
|
||||
$tags = $repository->get()->sortBy(
|
||||
function (Tag $tag) {
|
||||
return $tag->tag;
|
||||
}
|
||||
);
|
||||
$tags = $repository->get();
|
||||
try {
|
||||
$result = view('reports.options.tag', compact('tags'))->render();
|
||||
} catch (Throwable $e) {
|
||||
|
@@ -208,7 +208,7 @@ trait RequestInformation
|
||||
*/
|
||||
protected function getSpecificPageName(): string // get request info
|
||||
{
|
||||
return null === RouteFacade::current()->parameter('what') ? '' : '_' . RouteFacade::current()->parameter('what');
|
||||
return null === RouteFacade::current()->parameter('objectType') ? '' : '_' . RouteFacade::current()->parameter('objectType');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -59,7 +59,7 @@ class General extends Twig_Extension
|
||||
$this->phpdate(),
|
||||
$this->activeRouteStrict(),
|
||||
$this->activeRoutePartial(),
|
||||
$this->activeRoutePartialWhat(),
|
||||
$this->activeRoutePartialObjectType(),
|
||||
$this->formatDate(),
|
||||
$this->getMetaField(),
|
||||
$this->hasRole(),
|
||||
@@ -77,7 +77,7 @@ class General extends Twig_Extension
|
||||
return new Twig_SimpleFunction(
|
||||
'activeRoutePartial',
|
||||
function (): string {
|
||||
$args = \func_get_args();
|
||||
$args = func_get_args();
|
||||
$route = $args[0]; // name of the route.
|
||||
$name = Route::getCurrentRoute()->getName() ?? '';
|
||||
if (!(false === strpos($name, $route))) {
|
||||
@@ -95,15 +95,15 @@ class General extends Twig_Extension
|
||||
*
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
protected function activeRoutePartialWhat(): Twig_SimpleFunction
|
||||
protected function activeRoutePartialObjectType(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'activeRoutePartialWhat',
|
||||
function ($context): string {
|
||||
[, $route, $what] = func_get_args();
|
||||
$activeWhat = $context['what'] ?? false;
|
||||
'activeRoutePartialObjectType',
|
||||
static function ($context): string {
|
||||
[, $route, $objectType] = func_get_args();
|
||||
$activeObjectType = $context['objectType'] ?? false;
|
||||
|
||||
if ($what === $activeWhat && !(false === stripos(Route::getCurrentRoute()->getName(), $route))) {
|
||||
if ($objectType === $activeObjectType && !(false === stripos(Route::getCurrentRoute()->getName(), $route))) {
|
||||
return 'active';
|
||||
}
|
||||
|
||||
@@ -347,5 +347,4 @@ class General extends Twig_Extension
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user