HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/ipsremont-demo/app/Services/Settings/SettingsService.php
<?php

namespace App\Services\Settings;

use App\Http\Requests\Settings\UpdateRequest;
use App\Repository\Settings\SettingsRepository;

class SettingsService
{

    protected SettingsRepository $repository;

    public function __construct()
    {
        $this->repository = new SettingsRepository();
    }

    public static function getField($key): \App\Models\Settings
    {
        return SettingsRepository::getField($key);
    }

    public function update(UpdateRequest $request)
    {
        $this->repository->update($request);
        $this->setConfig();
    }

    protected function setConfig()
    {
        $from = "<?php
          return [
            'address' => '{email}',
            'name' => '{name}',
        ];
        ";
        $from = str_replace('{email}', SettingsRepository::getField('email')->value, $from);
        $from = str_replace('{name}', SettingsRepository::getField('name')->value, $from);
        file_put_contents(base_path() . '/config/from.php', $from);

        $smtp = "<?php
            return [
                'transport' => 'smtp',
                'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
                'port' => env('MAIL_PORT', 587),
                'encryption' => env('MAIL_ENCRYPTION', 'tls'),

                'username' => '{email}',
                'password' => '{password}',

                'timeout' => null,
                'auth_mode' => null,
            ];
        ";
        $smtp = str_replace('{email}', SettingsRepository::getField('email')->value, $smtp);
        $smtp = str_replace('{password}', SettingsRepository::getField('password')->value, $smtp);
        file_put_contents(base_path() . '/config/smtp.php', $smtp);
    }
}