mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-10 17:09:42 +00:00
PHPStorm can order methods by alphabet, who knew.
This commit is contained in:
@@ -65,32 +65,6 @@ class BelongsUser implements ValidationRule
|
||||
}
|
||||
}
|
||||
|
||||
protected function countField(string $class, string $field, string $value): int
|
||||
{
|
||||
$value = trim($value);
|
||||
$objects = [];
|
||||
// get all objects belonging to user:
|
||||
if (PiggyBank::class === $class) {
|
||||
$objects = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
|
||||
->where('accounts.user_id', '=', auth()->user()->id)->get(['piggy_banks.*'])
|
||||
;
|
||||
}
|
||||
if (PiggyBank::class !== $class) {
|
||||
$objects = $class::where('user_id', '=', auth()->user()->id)->get();
|
||||
}
|
||||
$count = 0;
|
||||
foreach ($objects as $object) {
|
||||
$objectValue = trim((string)$object->{$field}); // @phpstan-ignore-line
|
||||
app('log')->debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value));
|
||||
if ($objectValue === $value) {
|
||||
++$count;
|
||||
app('log')->debug(sprintf('Hit! Count is now %d', $count));
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
private function parseAttribute(string $attribute): string
|
||||
{
|
||||
$parts = explode('.', $attribute);
|
||||
@@ -121,6 +95,32 @@ class BelongsUser implements ValidationRule
|
||||
return 1 === $count;
|
||||
}
|
||||
|
||||
protected function countField(string $class, string $field, string $value): int
|
||||
{
|
||||
$value = trim($value);
|
||||
$objects = [];
|
||||
// get all objects belonging to user:
|
||||
if (PiggyBank::class === $class) {
|
||||
$objects = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
|
||||
->where('accounts.user_id', '=', auth()->user()->id)->get(['piggy_banks.*'])
|
||||
;
|
||||
}
|
||||
if (PiggyBank::class !== $class) {
|
||||
$objects = $class::where('user_id', '=', auth()->user()->id)->get();
|
||||
}
|
||||
$count = 0;
|
||||
foreach ($objects as $object) {
|
||||
$objectValue = trim((string)$object->{$field}); // @phpstan-ignore-line
|
||||
app('log')->debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value));
|
||||
if ($objectValue === $value) {
|
||||
++$count;
|
||||
app('log')->debug(sprintf('Hit! Count is now %d', $count));
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
private function validateBillId(int $value): bool
|
||||
{
|
||||
if (0 === $value) {
|
||||
|
||||
@@ -78,32 +78,6 @@ class BelongsUserGroup implements ValidationRule
|
||||
}
|
||||
}
|
||||
|
||||
protected function countField(string $class, string $field, string $value): int
|
||||
{
|
||||
$value = trim($value);
|
||||
$objects = [];
|
||||
// get all objects belonging to user:
|
||||
if (PiggyBank::class === $class) {
|
||||
$objects = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
|
||||
->where('accounts.user_group_id', '=', $this->userGroup->id)->get(['piggy_banks.*'])
|
||||
;
|
||||
}
|
||||
if (PiggyBank::class !== $class) {
|
||||
$objects = $class::where('user_group_id', '=', $this->userGroup->id)->get();
|
||||
}
|
||||
$count = 0;
|
||||
foreach ($objects as $object) {
|
||||
$objectValue = trim((string)$object->{$field}); // @phpstan-ignore-line
|
||||
app('log')->debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value));
|
||||
if ($objectValue === $value) {
|
||||
++$count;
|
||||
app('log')->debug(sprintf('Hit! Count is now %d', $count));
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
private function parseAttribute(string $attribute): string
|
||||
{
|
||||
$parts = explode('.', $attribute);
|
||||
@@ -134,6 +108,32 @@ class BelongsUserGroup implements ValidationRule
|
||||
return 1 === $count;
|
||||
}
|
||||
|
||||
protected function countField(string $class, string $field, string $value): int
|
||||
{
|
||||
$value = trim($value);
|
||||
$objects = [];
|
||||
// get all objects belonging to user:
|
||||
if (PiggyBank::class === $class) {
|
||||
$objects = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
|
||||
->where('accounts.user_group_id', '=', $this->userGroup->id)->get(['piggy_banks.*'])
|
||||
;
|
||||
}
|
||||
if (PiggyBank::class !== $class) {
|
||||
$objects = $class::where('user_group_id', '=', $this->userGroup->id)->get();
|
||||
}
|
||||
$count = 0;
|
||||
foreach ($objects as $object) {
|
||||
$objectValue = trim((string)$object->{$field}); // @phpstan-ignore-line
|
||||
app('log')->debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value));
|
||||
if ($objectValue === $value) {
|
||||
++$count;
|
||||
app('log')->debug(sprintf('Hit! Count is now %d', $count));
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
private function validateBillId(int $value): bool
|
||||
{
|
||||
if (0 === $value) {
|
||||
|
||||
@@ -57,6 +57,15 @@ class IsValidAttachmentModel implements ValidationRule
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
private function normalizeModel(string $model): string
|
||||
{
|
||||
$search = ['FireflyIII\Models\\'];
|
||||
$replace = '';
|
||||
$model = str_replace($search, $replace, $model);
|
||||
|
||||
return sprintf('FireflyIII\Models\%s', $model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
@@ -84,15 +93,6 @@ class IsValidAttachmentModel implements ValidationRule
|
||||
}
|
||||
}
|
||||
|
||||
private function normalizeModel(string $model): string
|
||||
{
|
||||
$search = ['FireflyIII\Models\\'];
|
||||
$replace = '';
|
||||
$model = str_replace($search, $replace, $model);
|
||||
|
||||
return sprintf('FireflyIII\Models\%s', $model);
|
||||
}
|
||||
|
||||
private function validateAccount(int $value): bool
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
|
||||
@@ -64,7 +64,7 @@ class UniqueAccountNumber implements ValidationRule
|
||||
*/
|
||||
public function message(): string
|
||||
{
|
||||
return (string) trans('validation.unique_account_number_for_user');
|
||||
return (string)trans('validation.unique_account_number_for_user');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -146,10 +146,10 @@ class UniqueIban implements ValidationRule
|
||||
}
|
||||
$query
|
||||
= auth()->user()
|
||||
->accounts()
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->where('accounts.iban', $iban)
|
||||
->whereIn('account_types.type', $typesArray)
|
||||
->accounts()
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->where('accounts.iban', $iban)
|
||||
->whereIn('account_types.type', $typesArray)
|
||||
;
|
||||
|
||||
if (null !== $this->account) {
|
||||
|
||||
Reference in New Issue
Block a user