From 293d9913c65143f00e3051bff32d15c97644bd15 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 1 Aug 2024 17:32:20 +1000 Subject: [PATCH] Fix LeenooksCarbon casting with null values, move select2 to PageAssets --- src/Casts/LeenooksCarbon.php | 4 +-- src/PageAssets.php | 15 +++++++++++ src/Providers/CustomBladeServiceProvider.php | 28 +------------------- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/src/Casts/LeenooksCarbon.php b/src/Casts/LeenooksCarbon.php index 72aaba5..0b9341f 100644 --- a/src/Casts/LeenooksCarbon.php +++ b/src/Casts/LeenooksCarbon.php @@ -23,8 +23,8 @@ class LeenooksCarbon implements CastsAttributes * * @param array $attributes */ - public function set(Model $model, string $key, mixed $value, array $attributes): string + public function set(Model $model, string $key, mixed $value, array $attributes): string|null { - return ($value instanceof Carbon ? $value : $this->get($model,$key,$value,$attributes))->format('Y-m-d H:i:s'); + return ($value instanceof Carbon ? $value : $this->get($model,$key,$value,$attributes))?->format('Y-m-d H:i:s'); } } diff --git a/src/PageAssets.php b/src/PageAssets.php index ed0d130..f051c31 100644 --- a/src/PageAssets.php +++ b/src/PageAssets.php @@ -106,6 +106,21 @@ class PageAssets ] ], ], + 'select2' => [ + 'base' => [ + 'css' => [ + '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css', + ], + 'js' => [ + '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js', + ], + ], + 'autofocus' => [ + 'js' => [ + '/plugin/select2/fix-autofocus.js', + ], + ] + ], ]; // Items to manage diff --git a/src/Providers/CustomBladeServiceProvider.php b/src/Providers/CustomBladeServiceProvider.php index 1ea1dc6..bb92989 100644 --- a/src/Providers/CustomBladeServiceProvider.php +++ b/src/Providers/CustomBladeServiceProvider.php @@ -41,6 +41,7 @@ class CustomBladeServiceProvider extends ServiceProvider switch ($type) { case 'datatables': + case 'select2': Log::alert(sprintf('Blade @css/@js for %s deprecicated, use @pa',$type)); break; @@ -146,33 +147,6 @@ class CustomBladeServiceProvider extends ServiceProvider break; - case 'select2': - switch ($content) { - case 'css': - // Base - $css->put($type,'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css'); - - break; - - case 'js': - // Base - $js->put($type,'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js'); - - foreach ($arguments as $option) { - $key = $type.':'.$option; - switch ($option) { - case 'autofocus': - $js->put($key,'/plugin/select2/fix-autofocus.js'); - break; - - default: - throw new \Exception(sprintf('Unknown [%s] option: [%s:%s]',$type,$content,$option)); - } - } - } - - break; - case 'simplemde': switch ($content) { case 'css':