Skip to content

Commit

Permalink
fixed app url issue
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed May 17, 2021
1 parent 03c960d commit bdb51a2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions .env.example
Expand Up @@ -5,6 +5,7 @@ APP_INSTALLED=false
APP_KEY=
APP_DEBUG=true
APP_SCHEDULE_TIME="09:00"
APP_URL=

DB_CONNECTION=mysql
DB_HOST=localhost
Expand Down
1 change: 1 addition & 0 deletions .env.testing
Expand Up @@ -5,6 +5,7 @@ APP_INSTALLED=true
APP_KEY=base64:xBC+BxlC7sXhYAtpTZv8TYAHqoPgsJaXL0S5Id6BbBc=
APP_DEBUG=true
APP_SCHEDULE_TIME="09:00"
APP_URL=

DB_CONNECTION=sqlite
DB_DATABASE=:memory:
Expand Down
22 changes: 14 additions & 8 deletions app/Utilities/Installer.php
Expand Up @@ -5,10 +5,10 @@
use App\Jobs\Auth\CreateUser;
use App\Jobs\Common\CreateCompany;
use App\Utilities\Console;
use Artisan;
use Config;
use DB;
use File;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;

/**
Expand Down Expand Up @@ -232,7 +232,7 @@ public static function saveDbVariables($host, $port, $database, $username, $pass

public static function createCompany($name, $email, $locale)
{
dispatch_now(new CreateCompany([
dispatch_sync(new CreateCompany([
'name' => $name,
'domain' => '',
'email' => $email,
Expand All @@ -244,7 +244,7 @@ public static function createCompany($name, $email, $locale)

public static function createUser($email, $password, $locale)
{
dispatch_now(new CreateUser([
dispatch_sync(new CreateUser([
'name' => '',
'email' => $email,
'password' => $password,
Expand All @@ -258,13 +258,19 @@ public static function createUser($email, $password, $locale)
public static function finalTouches()
{
// Update .env file
static::updateEnv([
$env = [
'APP_LOCALE' => session('locale'),
'APP_INSTALLED' => 'true',
'APP_DEBUG' => 'false',
'FIREWALL_ENABLED' => 'true',
'MODEL_CACHE_ENABLED' => 'true',
]);
];

if (!app()->runningInConsole()) {
$env['APP_URL'] = request()->getUriForPath('');
}

static::updateEnv($env);

// Rename the robots.txt file
try {
Expand Down
6 changes: 4 additions & 2 deletions app/Utilities/Overrider.php
Expand Up @@ -50,8 +50,10 @@ protected static function loadSettings()
app()->setLocale(setting('default.locale'));
}

// Set app url dynamically
config(['app.url' => url('/')]);
// Set app url dynamically if empty
if (!config('app.url')) {
config(['app.url' => url('/')]);
}
}

protected static function loadCurrencies()
Expand Down
2 changes: 1 addition & 1 deletion config/app.php
Expand Up @@ -55,7 +55,7 @@
|
*/

'url' => env('APP_URL', 'http://localhost'),
'url' => env('APP_URL', ''),

'asset_url' => env('ASSET_URL', null),

Expand Down

0 comments on commit bdb51a2

Please sign in to comment.