diff --git a/src/Builder.php b/src/Builder.php index caf1dfd..c2d248b 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -162,7 +162,7 @@ public function render() $inLivewire = $chart['inLivewire'] ?? false; $view = $inLivewire ? 'chart-template::chart-template-livewire' : Config::getChartViewName(); // Should probably add another config setting for the Livewire version - $optionsRaw = isset($chart['optionsRaw']) ? $chart['optionsRaw'] : null; + $optionsRaw = $chart['optionsRaw'] ?? null; $optionsSimple = isset($chart['options']) ? json_encode($chart['options']) : null; $options = $optionsRaw ? $optionsRaw : $optionsSimple; diff --git a/src/Providers/ChartjsServiceProvider.php b/src/Providers/ChartjsServiceProvider.php index fdfcd4a..d7ec92e 100755 --- a/src/Providers/ChartjsServiceProvider.php +++ b/src/Providers/ChartjsServiceProvider.php @@ -21,7 +21,6 @@ public function boot() $this->colours = config('chartjs.colours'); // Installation and setup - $this->publishes([ __DIR__.'/../../config/chartjs.php' => config_path('chartjs.php'), ], 'config'); @@ -45,13 +44,11 @@ public function boot() // Delivery and view injection if(config('chartjs.delivery') == 'binary') { - if(config('chartjs.version') == 4) { view()->composer('chart-template::chart-template', function ($view) { $view->with('chartJsScriptv4', file_get_contents(base_path('vendor/icehouse-ventures/laravel-chartjs/dist/chart.js'))); }); - } - elseif(config('chartjs.version') == 3) { + } elseif(config('chartjs.version') == 3) { view()->composer('chart-template::chart-template', function ($view) { $view->with('chartJsScriptv3', file_get_contents(base_path('vendor/icehouse-ventures/laravel-chartjs/dist/chart3.js'))); }); diff --git a/src/Support/Config.php b/src/Support/Config.php index 397fe57..8e9f20b 100644 --- a/src/Support/Config.php +++ b/src/Support/Config.php @@ -8,7 +8,7 @@ class Config { public static function allowedChartTypes() { - if(self::chartJsVersion() > 3) { + if (self::chartJsVersion() > 3) { return ['bar', 'bubble', 'scatter', 'doughnut', 'line', 'pie', 'polarArea', 'radar']; } return ['bar', 'horizontalBar', 'bubble', 'scatter', 'doughnut', 'line', 'pie', 'polarArea', 'radar']; @@ -31,15 +31,18 @@ public static function dateAdapter() public static function useCustomView() { - if(!config('chartjs.custom_view')) { + if (!config('chartjs.custom_view')) { return false; } - if(config('chartjs.custom_view') === 'false') { + + if (config('chartjs.custom_view') === 'false') { return false; } - if(config('chartjs.custom_view')) { + + if (config('chartjs.custom_view')) { return true; } + return false; } @@ -47,6 +50,7 @@ public static function getChartViewName() { if (self::useCustomView()) { $customViewPath = resource_path('views/vendor/laravelchartjs/custom-chart-template.blade.php'); + if (File::exists($customViewPath)) { return 'vendor.laravelchartjs.custom-chart-template'; }