Convert env() to config()

Laravel [recommends][1] only using `env()` within configuration files and using `config()` everywhere else. Doing so allows you to improve performance by running `php artisan config:cache`.

[1]: https://laravel.com/docs/5.7/configuration#configuration-caching
This commit is contained in:
Shift
2023-03-30 14:15:18 +00:00
parent 1eeb9eaece
commit 9075b09068
4 changed files with 14 additions and 6 deletions
@@ -164,7 +164,7 @@ class AdminSiteController extends BasePageController
$this->smarty->assign('themelist', Utility::getThemesList());
if (! str_contains(env('NNTP_SERVER'), 'astra')) {
if (! str_contains(config('settings.nntp_server'), 'astra')) {
$this->smarty->assign('compress_headers_warning', 'compress_headers_warning');
}
@@ -232,7 +232,7 @@ class RegisterController extends Controller
app('smarty.view')->assign('invite_code_query', $this->inviteCodeQuery);
$theme = Settings::settingValue('site.main.style');
$nocaptcha = env('NOCAPTCHA_ENABLED');
$nocaptcha = config('settings.nocaptcha_enabled');
$meta_title = 'Register';
$meta_keywords = 'register,signup,registration';
@@ -15,8 +15,8 @@ class BtcPaymentController extends BasePageController
public function show(Request $request): \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
{
$this->setPreferences();
$gateway_id = env('MYCELIUM_GATEWAY_ID');
$gateway_secret = env('MYCELIUM_GATEWAY_SECRET');
$gateway_id = config('settings.mycelium_gateway_id');
$gateway_secret = config('settings.mycelium_gateway_secret');
$action = $request->input('action') ?? 'view';
$donation = Role::query()->where('donation', '>', 0)->get(['id', 'name', 'donation', 'addyears']);
@@ -63,8 +63,8 @@ class BtcPaymentController extends BasePageController
*/
public function callback(): void
{
$gateway_id = env('MYCELIUM_GATEWAY_ID');
$gateway_secret = env('MYCELIUM_GATEWAY_SECRET');
$gateway_id = config('settings.mycelium_gateway_id');
$gateway_secret = config('settings.mycelium_gateway_secret');
$geary = new Geary($gateway_id, $gateway_secret);
$order = $geary->check_order_callback();
+8
View File
@@ -0,0 +1,8 @@
<?php
return [
'mycelium_gateway_id' => env('MYCELIUM_GATEWAY_ID'),
'mycelium_gateway_secret' => env('MYCELIUM_GATEWAY_SECRET'),
'nntp_server' => env('NNTP_SERVER'),
'nocaptcha_enabled' => env('NOCAPTCHA_ENABLED'),
];