mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-09 03:08:09 +00:00
Move to object held user object.
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace FireflyIII\Repositories\Account;
|
namespace FireflyIII\Repositories\Account;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Config;
|
use Config;
|
||||||
use DB;
|
use DB;
|
||||||
@@ -52,7 +51,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function countAccounts(array $types): int
|
public function countAccounts(array $types): int
|
||||||
{
|
{
|
||||||
$count = Auth::user()->accounts()->accountTypeIn($types)->count();
|
$count = $this->user->accounts()->accountTypeIn($types)->count();
|
||||||
|
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
@@ -84,7 +83,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function find(int $accountId): Account
|
public function find(int $accountId): Account
|
||||||
{
|
{
|
||||||
return Auth::user()->accounts()->findOrNew($accountId);
|
return $this->user->accounts()->findOrNew($accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +106,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
public function getAccounts(array $types): Collection
|
public function getAccounts(array $types): Collection
|
||||||
{
|
{
|
||||||
/** @var Collection $result */
|
/** @var Collection $result */
|
||||||
$result = Auth::user()->accounts()->with(
|
$result = $this->user->accounts()->with(
|
||||||
['accountmeta' => function (HasMany $query) {
|
['accountmeta' => function (HasMany $query) {
|
||||||
$query->where('name', 'accountRole');
|
$query->where('name', 'accountRole');
|
||||||
}]
|
}]
|
||||||
@@ -135,7 +134,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getCreditCards(Carbon $date): Collection
|
public function getCreditCards(Carbon $date): Collection
|
||||||
{
|
{
|
||||||
$set = Auth::user()->accounts()
|
$set = $this->user->accounts()
|
||||||
->hasMetaValue('accountRole', 'ccAsset')
|
->hasMetaValue('accountRole', 'ccAsset')
|
||||||
->hasMetaValue('ccType', 'monthlyFull')
|
->hasMetaValue('ccType', 'monthlyFull')
|
||||||
->leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
|
->leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
|
||||||
@@ -178,7 +177,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getFrontpageAccounts(Preference $preference): Collection
|
public function getFrontpageAccounts(Preference $preference): Collection
|
||||||
{
|
{
|
||||||
$query = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account']);
|
$query = $this->user->accounts()->accountTypeIn(['Default account', 'Asset account']);
|
||||||
|
|
||||||
if (count($preference->data) > 0) {
|
if (count($preference->data) > 0) {
|
||||||
$query->whereIn('accounts.id', $preference->data);
|
$query->whereIn('accounts.id', $preference->data);
|
||||||
@@ -202,7 +201,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end): Collection
|
public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end): Collection
|
||||||
{
|
{
|
||||||
$set = Auth::user()
|
$set = $this->user
|
||||||
->transactionjournals()
|
->transactionjournals()
|
||||||
->with(['transactions'])
|
->with(['transactions'])
|
||||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
@@ -229,7 +228,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
public function getJournals(Account $account, $page): LengthAwarePaginator
|
public function getJournals(Account $account, $page): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
$offset = ($page - 1) * 50;
|
$offset = ($page - 1) * 50;
|
||||||
$query = Auth::user()
|
$query = $this->user
|
||||||
->transactionJournals()
|
->transactionJournals()
|
||||||
->withRelevantData()
|
->withRelevantData()
|
||||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
@@ -262,7 +261,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
|
|
||||||
$ids = array_unique($ids);
|
$ids = array_unique($ids);
|
||||||
if (count($ids) > 0) {
|
if (count($ids) > 0) {
|
||||||
$accounts = Auth::user()->accounts()->whereIn('id', $ids)->where('accounts.active', 1)->get();
|
$accounts = $this->user->accounts()->whereIn('id', $ids)->where('accounts.active', 1)->get();
|
||||||
}
|
}
|
||||||
bcscale(2);
|
bcscale(2);
|
||||||
|
|
||||||
@@ -296,7 +295,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getSavingsAccounts(): Collection
|
public function getSavingsAccounts(): Collection
|
||||||
{
|
{
|
||||||
$accounts = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')
|
$accounts = $this->user->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')
|
||||||
->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
|
->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
|
||||||
->where('account_meta.name', 'accountRole')
|
->where('account_meta.name', 'accountRole')
|
||||||
->where('accounts.active', 1)
|
->where('accounts.active', 1)
|
||||||
@@ -426,7 +425,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function sumOfEverything(): string
|
public function sumOfEverything(): string
|
||||||
{
|
{
|
||||||
return strval(Auth::user()->transactions()->sum('amount'));
|
return strval($this->user->transactions()->sum('amount'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user