fixed #132
This commit is contained in:
		@@ -123,6 +123,10 @@ class Requirements extends Controller
 | 
				
			|||||||
                'key'       => 'APP_ENV',
 | 
					                'key'       => 'APP_ENV',
 | 
				
			||||||
                'value'     => 'production',
 | 
					                'value'     => 'production',
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
 | 
					            [
 | 
				
			||||||
 | 
					                'key'       => 'APP_LOCALE',
 | 
				
			||||||
 | 
					                'value'     => 'en-GB',
 | 
				
			||||||
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key'       => 'APP_INSTALLED',
 | 
					                'key'       => 'APP_INSTALLED',
 | 
				
			||||||
                'value'     => 'false',
 | 
					                'value'     => 'false',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -88,6 +88,10 @@ class Settings extends Controller
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Update .env file
 | 
					        // Update .env file
 | 
				
			||||||
        DotenvEditor::setKeys([
 | 
					        DotenvEditor::setKeys([
 | 
				
			||||||
 | 
					            [
 | 
				
			||||||
 | 
					                'key'       => 'APP_LOCALE',
 | 
				
			||||||
 | 
					                'value'     => session('locale'),
 | 
				
			||||||
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key'       => 'APP_INSTALLED',
 | 
					                'key'       => 'APP_INSTALLED',
 | 
				
			||||||
                'value'     => 'true',
 | 
					                'value'     => 'true',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,13 +5,14 @@ namespace App\Http\Controllers\Settings;
 | 
				
			|||||||
use App\Http\Controllers\Controller;
 | 
					use App\Http\Controllers\Controller;
 | 
				
			||||||
use App\Http\Requests\Setting\Setting as Request;
 | 
					use App\Http\Requests\Setting\Setting as Request;
 | 
				
			||||||
use App\Models\Banking\Account;
 | 
					use App\Models\Banking\Account;
 | 
				
			||||||
 | 
					use App\Models\Company\Company;
 | 
				
			||||||
use App\Models\Setting\Currency;
 | 
					use App\Models\Setting\Currency;
 | 
				
			||||||
use App\Models\Setting\Tax;
 | 
					 | 
				
			||||||
use App\Models\Setting\Setting;
 | 
					use App\Models\Setting\Setting;
 | 
				
			||||||
 | 
					use App\Models\Setting\Tax;
 | 
				
			||||||
use App\Traits\DateTime;
 | 
					use App\Traits\DateTime;
 | 
				
			||||||
use App\Traits\Uploads;
 | 
					use App\Traits\Uploads;
 | 
				
			||||||
 | 
					 | 
				
			||||||
use App\Utilities\Modules;
 | 
					use App\Utilities\Modules;
 | 
				
			||||||
 | 
					use DotenvEditor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Settings extends Controller
 | 
					class Settings extends Controller
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -90,6 +91,8 @@ class Settings extends Controller
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        $skip_keys = ['company_id', '_method', '_token'];
 | 
					        $skip_keys = ['company_id', '_method', '_token'];
 | 
				
			||||||
        $file_keys = ['company_logo', 'invoice_logo'];
 | 
					        $file_keys = ['company_logo', 'invoice_logo'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $companies = Company::all()->count();
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        foreach ($fields as $key => $value) {
 | 
					        foreach ($fields as $key => $value) {
 | 
				
			||||||
            // Don't process unwanted keys
 | 
					            // Don't process unwanted keys
 | 
				
			||||||
@@ -107,6 +110,17 @@ class Settings extends Controller
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Change default locale if only 1 company
 | 
				
			||||||
 | 
					            if (($key == 'default_locale') && ($companies == 1)) {
 | 
				
			||||||
 | 
					                // Update .env file
 | 
				
			||||||
 | 
					                DotenvEditor::setKeys([
 | 
				
			||||||
 | 
					                    [
 | 
				
			||||||
 | 
					                        'key'       => 'APP_LOCALE',
 | 
				
			||||||
 | 
					                        'value'     => $value,
 | 
				
			||||||
 | 
					                    ],
 | 
				
			||||||
 | 
					                ])->save();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            setting()->set('general.' . $key, $value);
 | 
					            setting()->set('general.' . $key, $value);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										43
									
								
								app/Listeners/Updates/Version111.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								app/Listeners/Updates/Version111.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace App\Listeners\Updates;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use App\Events\UpdateFinished;
 | 
				
			||||||
 | 
					use App\Models\Company\Company;
 | 
				
			||||||
 | 
					use DotenvEditor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Version111 extends Listener
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const ALIAS = 'core';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const VERSION = '1.1.1';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Handle the event.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param  $event
 | 
				
			||||||
 | 
					     * @return void
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function handle(UpdateFinished $event)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Check if should listen
 | 
				
			||||||
 | 
					        if (!$this->check($event)) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $locale = 'en-GB';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Get default locale if only 1 company
 | 
				
			||||||
 | 
					        if (Company::all()->count() == 1) {
 | 
				
			||||||
 | 
					            $locale = setting('general.default_locale', 'en-GB');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Set default locale
 | 
				
			||||||
 | 
					        DotenvEditor::setKeys([
 | 
				
			||||||
 | 
					            [
 | 
				
			||||||
 | 
					                'key'       => 'APP_LOCALE',
 | 
				
			||||||
 | 
					                'value'     => $locale,
 | 
				
			||||||
 | 
					            ],
 | 
				
			||||||
 | 
					        ])->save();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -77,7 +77,7 @@ return [
 | 
				
			|||||||
    |
 | 
					    |
 | 
				
			||||||
    */
 | 
					    */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    'locale' => 'en-GB',
 | 
					    'locale' => env('APP_LOCALE', 'en-GB'),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*
 | 
					    /*
 | 
				
			||||||
    |--------------------------------------------------------------------------
 | 
					    |--------------------------------------------------------------------------
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user