diff --git a/composer.json b/composer.json index 98c70c4..87143f1 100644 --- a/composer.json +++ b/composer.json @@ -30,6 +30,9 @@ "spatie/laravel-ray": "^1.26" }, "autoload": { + "files": [ + "src/helpers.php" + ], "psr-4": { "Saade\\FilamentFullCalendar\\": "src" } diff --git a/src/Widgets/Concerns/InteractsWithConfig.php b/src/Widgets/Concerns/CanBeConfigured.php similarity index 75% rename from src/Widgets/Concerns/InteractsWithConfig.php rename to src/Widgets/Concerns/CanBeConfigured.php index 7def752..15e5eda 100644 --- a/src/Widgets/Concerns/InteractsWithConfig.php +++ b/src/Widgets/Concerns/CanBeConfigured.php @@ -4,6 +4,8 @@ use Saade\FilamentFullCalendar\FilamentFullCalendarPlugin; +use function Saade\FilamentFullCalendar\array_merge_recursive_unique; + trait CanBeConfigured { public function config(): array @@ -11,11 +13,9 @@ public function config(): array return []; } - - protected function getConfig(): array { - return array_merge_recursive( + return array_merge_recursive_unique( FilamentFullCalendarPlugin::get()->getConfig(), $this->config(), ); diff --git a/src/helpers.php b/src/helpers.php new file mode 100644 index 0000000..d835fda --- /dev/null +++ b/src/helpers.php @@ -0,0 +1,17 @@ + $value) { + if (is_array($value) && isset($array1[$key]) && is_array($array1[$key])) { + $array1[$key] = array_merge_recursive_unique($array1[$key], $value); + } else { + $array1[$key] = $value; + } + } + + return $array1; + } +} \ No newline at end of file