Skip to content

Commit b7f19df

Browse files
committed
Removed view composer and replace with view share
1 parent 582d854 commit b7f19df

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/LaravelCrmServiceProvider.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Illuminate\Support\Collection;
1212
use Illuminate\Support\Facades\Gate;
1313
use Illuminate\Support\Facades\Route;
14+
use Illuminate\Support\Facades\Schema;
1415
use Illuminate\Support\ServiceProvider;
1516
use Livewire\Livewire;
1617
use VentureDrake\LaravelCrm\Console\LaravelCrmAddressTypes;
@@ -479,9 +480,16 @@ function ($perPage = 30, $page = null, $options = []) {
479480
});
480481
}
481482

482-
view()->composer('laravel-crm::layouts.app', SettingsComposer::class);
483-
view()->composer('laravel-crm::layouts.document', SettingsComposer::class);
484-
view()->composer('laravel-crm::layouts.portal', SettingsComposer::class);
483+
// This was causing composer install post dump autoload to fail when no DB connected
484+
if (! $this->app->runningInConsole()) {
485+
if (Schema::hasTable(config('laravel-crm.db_table_prefix').'settings')) {
486+
view()->share('dateFormat', Setting::where('name', 'date_format')->first()->value ?? 'Y/m/d');
487+
view()->share('timeFormat', Setting::where('name', 'time_format')->first()->value ?? 'H:i');
488+
} else {
489+
view()->share('dateFormat', 'Y/m/d');
490+
view()->share('timeFormat', 'H:i');
491+
}
492+
}
485493
}
486494

487495
/**

0 commit comments

Comments
 (0)