Closed atmonshi closed 6 months ago
I see now if not pro: an empty array item. But why not the array_filter() ? As it completely removes that item from the list. .. thank you for fast fix 👌🏻
🤔 can you explain how to use it with conditional array item?
...Bolt::hasPro() ? \LaraZeus\BoltPro\Facades\GradeOptions::schema($field) : [],
well i only meant it for this function:
public static function getOptionsHidden(): array
{
return [
// @phpstan-ignore-next-line
Bolt::hasPro() ? \LaraZeus\BoltPro\Facades\GradeOptions::hidden() : null,
self::hiddenDataSource(),
self::hiddenVisibility(),
self::hiddenHtmlID(),
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
];
}
wrap the array with array_filter() function like so:
public static function getOptionsHidden(): array
{
return array_filter([
// @phpstan-ignore-next-line
Bolt::hasPro() ? \LaraZeus\BoltPro\Facades\GradeOptions::hidden() : null,
self::hiddenDataSource(),
self::hiddenVisibility(),
self::hiddenHtmlID(),
self::hiddenHintOptions(),
self::hiddenRequired(),
self::hiddenColumnSpanFull(),
]);
}
it will completely remove the null / empty array items, so you don't have an empty array item in the array which you return. Keeps the return array of getOptionsHidden() clean.
you're right, but instead of duplicate the array_filter
on all classes I am already cleaning it up when been called here :)
Ah didn't see that one in the commits. you already found a way. that's perfect!
PR Summary
Bolt::hasPro()
Condition Across Multiple Classes This update fundamentally improves the handling of certain data within theCheckboxList
,DatePicker
,DateTimePicker
,Paragraph
,Radio
,RichEditor
,Select
,TextInput
,Textarea
,TimePicker
, andToggle
service classes. Initially, the system was returningnull
under certain conditions. After applying this change, the system is configured to return an empty array[]
instead ofnull
. This improvement is aimed at averting potential system errors and ensuring a more stable performance.