Fix LeenooksCarbon casting with null values, move select2 to PageAssets

This commit is contained in:
Deon George 2024-08-01 17:32:20 +10:00
parent 8acc3a91af
commit 293d9913c6
3 changed files with 18 additions and 29 deletions

View File

@ -23,8 +23,8 @@ class LeenooksCarbon implements CastsAttributes
*
* @param array<string, mixed> $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');
}
}

View File

@ -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

View File

@ -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':