Skip to content

Commit

Permalink
Removed view composer and replace with view share
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdrake committed Apr 23, 2023
1 parent 582d854 commit b7f19df
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/LaravelCrmServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;
use VentureDrake\LaravelCrm\Console\LaravelCrmAddressTypes;
Expand Down Expand Up @@ -479,9 +480,16 @@ function ($perPage = 30, $page = null, $options = []) {
});
}

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

/**
Expand Down

0 comments on commit b7f19df

Please sign in to comment.