Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for is pro not installed #295

Merged
merged 1 commit into from
May 31, 2024
Merged

fix for is pro not installed #295

merged 1 commit into from
May 31, 2024

Conversation

atmonshi
Copy link
Member

No description provided.

Copy link

what-the-diff bot commented May 31, 2024

PR Summary

  • Enhancement to Bolt::hasPro() Condition Across Multiple Classes
    This update fundamentally improves the handling of certain data within the CheckboxList, DatePicker, DateTimePicker, Paragraph, Radio, RichEditor, Select, TextInput, Textarea, TimePicker, and Toggle service classes. Initially, the system was returning null under certain conditions. After applying this change, the system is configured to return an empty array [] instead of null. This improvement is aimed at averting potential system errors and ensuring a more stable performance.

@eelco2k
Copy link

eelco2k commented May 31, 2024

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 👌🏻

@atmonshi
Copy link
Member Author

atmonshi commented Jun 6, 2024

🤔 can you explain how to use it with conditional array item?

...Bolt::hasPro() ? \LaraZeus\BoltPro\Facades\GradeOptions::schema($field) : [],

@eelco2k
Copy link

eelco2k commented Jun 6, 2024

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.

@atmonshi
Copy link
Member Author

atmonshi commented Jun 6, 2024

you're right, but instead of duplicate the array_filter on all classes I am already cleaning it up when been called here :)

@eelco2k
Copy link

eelco2k commented Jun 6, 2024

Ah didn't see that one in the commits. you already found a way. that's perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants