mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Clean up some code.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* NotificationRequest.php
|
||||
* Copyright (c) 2024 james@firefly-iii.org.
|
||||
@@ -35,24 +36,25 @@ class NotificationRequest extends FormRequest
|
||||
|
||||
public function getAll(): array
|
||||
{
|
||||
$return = [];
|
||||
$return = [];
|
||||
foreach (config('notifications.notifications.owner') as $key => $info) {
|
||||
$value = false;
|
||||
$value = false;
|
||||
if ($this->has(sprintf('notification_%s', $key))) {
|
||||
$value = true;
|
||||
}
|
||||
$return[$key] = $value;
|
||||
}
|
||||
$return['slack_webhook_url'] = $this->convertString('slack_webhook_url');
|
||||
$return['slack_webhook_url'] = $this->convertString('slack_webhook_url');
|
||||
|
||||
$return['pushover_app_token'] = $this->convertString('pushover_app_token');
|
||||
$return['pushover_user_token'] = $this->convertString('pushover_user_token');
|
||||
|
||||
$return['ntfy_server'] = $this->convertString('ntfy_server');
|
||||
$return['ntfy_topic'] = $this->convertString('ntfy_topic');
|
||||
$return['ntfy_auth'] = $this->convertBoolean($this->get('ntfy_auth'));
|
||||
$return['ntfy_user'] = $this->convertString('ntfy_user');
|
||||
$return['ntfy_pass'] = $this->convertString('ntfy_pass');
|
||||
$return['ntfy_server'] = $this->convertString('ntfy_server');
|
||||
$return['ntfy_topic'] = $this->convertString('ntfy_topic');
|
||||
$return['ntfy_auth'] = $this->convertBoolean($this->get('ntfy_auth'));
|
||||
$return['ntfy_user'] = $this->convertString('ntfy_user');
|
||||
$return['ntfy_pass'] = $this->convertString('ntfy_pass');
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -63,14 +65,14 @@ class NotificationRequest extends FormRequest
|
||||
{
|
||||
$rules = [
|
||||
'slack_webhook_url' => ['nullable', 'url', 'min:1', new IsValidSlackOrDiscordUrl()],
|
||||
'ntfy_server' => ['nullable', 'url', 'min:1'],
|
||||
'ntfy_user' => ['required_with:ntfy_pass,ntfy_auth', 'nullable', 'string', 'min:1'],
|
||||
'ntfy_pass' => ['required_with:ntfy_user,ntfy_auth', 'nullable', 'string', 'min:1'],
|
||||
'ntfy_server' => ['nullable', 'url', 'min:1'],
|
||||
'ntfy_user' => ['required_with:ntfy_pass,ntfy_auth', 'nullable', 'string', 'min:1'],
|
||||
'ntfy_pass' => ['required_with:ntfy_user,ntfy_auth', 'nullable', 'string', 'min:1'],
|
||||
];
|
||||
foreach (config('notifications.notifications.owner') as $key => $info) {
|
||||
$rules[sprintf('notification_%s', $key)] = 'in:0,1';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ class PiggyBankStoreRequest extends FormRequest
|
||||
$accounts = [];
|
||||
}
|
||||
foreach ($accounts as $item) {
|
||||
$data['accounts'][] = ['account_id' => (int) ($item)];
|
||||
$data['accounts'][] = ['account_id' => (int) $item];
|
||||
}
|
||||
|
||||
return $data;
|
||||
@@ -105,7 +105,7 @@ class PiggyBankStoreRequest extends FormRequest
|
||||
if ($accountCurrency->id !== $currency->id && 'true' !== $isMultiCurrency) {
|
||||
$validator->errors()->add('accounts', trans('validation.invalid_account_currency'));
|
||||
}
|
||||
$type = $account->accountType->type;
|
||||
$type = $account->accountType->type;
|
||||
if (!in_array($type, $types, true)) {
|
||||
$validator->errors()->add('accounts', trans('validation.invalid_account_type'));
|
||||
}
|
||||
@@ -127,6 +127,7 @@ class PiggyBankStoreRequest extends FormRequest
|
||||
if (null === $currency) {
|
||||
return app('amount')->getDefaultCurrency();
|
||||
}
|
||||
|
||||
return $currency;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user