From 270a44411da9c2c0ed4833e895253a0900fc1010 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Tue, 6 Nov 2018 14:00:30 +0300 Subject: [PATCH] fixed #594 --- .env.example | 2 ++ app/Http/Controllers/Settings/Settings.php | 16 ++++++++-------- app/Notifications/Auth/Reset.php | 2 -- app/Utilities/Installer.php | 8 ++++++++ .../views/vendor/mail/html/message.blade.php | 4 ++-- .../views/vendor/mail/markdown/message.blade.php | 4 ++-- .../views/vendor/notifications/email.blade.php | 2 +- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.env.example b/.env.example index e9f998867..c15b6a8d6 100644 --- a/.env.example +++ b/.env.example @@ -26,3 +26,5 @@ MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null +MAIL_FROM_NAME=null +MAIL_FROM_ADDRESS=null diff --git a/app/Http/Controllers/Settings/Settings.php b/app/Http/Controllers/Settings/Settings.php index 0f3006fd3..873d9c924 100644 --- a/app/Http/Controllers/Settings/Settings.php +++ b/app/Http/Controllers/Settings/Settings.php @@ -181,17 +181,17 @@ class Settings extends Controller protected function oneCompany($key, $value) { switch ($key) { + case 'company_name': + Installer::updateEnv(['MAIL_FROM_NAME' => '"' . $value . '"']); + break; + case 'company_email': + Installer::updateEnv(['MAIL_FROM_ADDRESS' => $value]); + break; case 'default_locale': - // Change default locale - Installer::updateEnv([ - 'APP_LOCALE' => $value - ]); + Installer::updateEnv(['APP_LOCALE' => $value]); break; case 'session_handler': - // Change session handler - Installer::updateEnv([ - 'SESSION_DRIVER' => $value - ]); + Installer::updateEnv(['SESSION_DRIVER' => $value]); break; } } diff --git a/app/Notifications/Auth/Reset.php b/app/Notifications/Auth/Reset.php index ef3c1752a..645a2de6b 100644 --- a/app/Notifications/Auth/Reset.php +++ b/app/Notifications/Auth/Reset.php @@ -43,8 +43,6 @@ class Reset extends Notification */ public function toMail($notifiable) { - setting(['general.company_name' => config('app.name')]); - return (new MailMessage) ->line(trans('auth.notification.message_1')) ->action(trans('auth.notification.button'), url('auth/reset', $this->token)) diff --git a/app/Utilities/Installer.php b/app/Utilities/Installer.php index 10eed40bc..c9d434b63 100644 --- a/app/Utilities/Installer.php +++ b/app/Utilities/Installer.php @@ -269,16 +269,24 @@ class Installer $env = explode("\n", $env); foreach ($data as $data_key => $data_value) { + $updated = false; + foreach ($env as $env_key => $env_value) { $entry = explode('=', $env_value, 2); // Check if new or old key if ($entry[0] == $data_key) { $env[$env_key] = $data_key . '=' . $data_value; + $updated = true; } else { $env[$env_key] = $env_value; } } + + // Lets create if not available + if (!$updated) { + $env[] = $data_key . '=' . $data_value; + } } $env = implode("\n", $env); diff --git a/resources/views/vendor/mail/html/message.blade.php b/resources/views/vendor/mail/html/message.blade.php index 413dbaf1d..26555409a 100644 --- a/resources/views/vendor/mail/html/message.blade.php +++ b/resources/views/vendor/mail/html/message.blade.php @@ -2,7 +2,7 @@ {{-- Header --}} @slot('header') @component('mail::header', ['url' => config('app.url')]) - {{ setting('general.company_name', config('app.name')) }} + {{ setting('general.company_name', config('mail.from.name', config('app.name'))) }} @endcomponent @endslot @@ -21,7 +21,7 @@ {{-- Footer --}} @slot('footer') @component('mail::footer') - © {{ date('Y') }} {{ setting('general.company_name', config('app.name')) }}. All rights reserved. + © {{ date('Y') }} {{ setting('general.company_name', config('mail.from.name', config('app.name'))) }}. All rights reserved. @endcomponent @endslot @endcomponent diff --git a/resources/views/vendor/mail/markdown/message.blade.php b/resources/views/vendor/mail/markdown/message.blade.php index 4792686d2..5b29ab63e 100644 --- a/resources/views/vendor/mail/markdown/message.blade.php +++ b/resources/views/vendor/mail/markdown/message.blade.php @@ -2,7 +2,7 @@ {{-- Header --}} @slot('header') @component('mail::header', ['url' => config('app.url')]) - {{ setting('general.company_name', config('app.name')) }} + {{ setting('general.company_name', config('mail.from.name', config('app.name'))) }} @endcomponent @endslot @@ -21,7 +21,7 @@ {{-- Footer --}} @slot('footer') @component('mail::footer') - © {{ date('Y') }} {{ setting('general.company_name', config('app.name')) }}. All rights reserved. + © {{ date('Y') }} {{ setting('general.company_name', config('mail.from.name', config('app.name'))) }}. All rights reserved. @endcomponent @endslot @endcomponent diff --git a/resources/views/vendor/notifications/email.blade.php b/resources/views/vendor/notifications/email.blade.php index e572533f3..cbdc6c29d 100644 --- a/resources/views/vendor/notifications/email.blade.php +++ b/resources/views/vendor/notifications/email.blade.php @@ -45,7 +45,7 @@ @if (! empty($salutation)) {{ $salutation }} @else -{!! trans('notifications.salutation', ['company_name' => setting('general.company_name', config('app.name'))]) !!} +{!! trans('notifications.salutation', ['company_name' => setting('general.company_name', config('mail.from.name', config('app.name')))]) !!} @endif