Spatie Settings with Filament CheckboxList

Hello gents.

I am posting here a topic which I've also posted in Filament but so far could not get any luck figuring out the things.

My idea was to build a Filament-Starter-Kit which can be freely used to download, install and have a full admin panel with Filament + Jetstreal (using last one to allow 2FA) + Settings page with an example for every input and many other plugins I manage to install like Spatie Roles& Permissions, Backup etc.

So I got all setup with latest filament + jetstream + Spatie settings and have built a Settings page with a few examples.

The issue started when I tried to add a Form CheckboxList input to Settings as I am defining the $settings_checkboxlist as string and Filament complained that I cannot store an array to a string type variable. If I try to set it up as an array type variable, Filament complains again that I am trying to store data to an array type variable, so I am stuck and can't move forward trying to figure out what is going on.

From what I am reading, to store the data, I somehow need to cast the $site_checkboxlist inside the GeneralSettings.php which extends the settings, but so far I could not figure it out how to cast it properly so that the data is stored and I can continue adding other fields.

long story short, how to store array data to Settings page...

Here is the link to the filament topic where I've shared also the link to the repo itself with the latest code...

β“β”ŠhelpSpatie Settings Checkboxlist

Any help is more than appreciated as I am trying to build complex admin in order to learn it, have some coding fun and share it with the community afterwords...
Solution
Nevermind, Tuto, I've figured it out, it was just that in the DB I did not define the initial column payload as [] but '' and not sure why but since I switched to that and set my variable as an array type, I got it working perfectly.

So my current settinfs page has the following definitions (in case you ever fall into this, despite I doubt it):

GeneralSettingsPage.php
 // All CheckboxList options: https://filamentphp.com/docs/3.x/forms/fields/checkbox-list
CheckboxList::make('site_checkboxlist') // checkbox list with supplied options
    ->options([
        '1' => '== A ==',
        '2' => '== B ==',
        '3' => '== C =='
    ]),


GeneralSettings.php
// Define the settings page inputs to use in the Settings Page
public array $site_checkboxlist; // Note: Changed this back to an array
...


And my settings table migration:
...
$this->migrator->add('general.site_checkboxlist', []); // checkbox list input
...


Just sharing the solution here, but the working code can be seen in the repo and I am moving forward with other inputs to see what hides there as well πŸ˜‰ At least I can handle arrays now in Filament to properly store the values... πŸ˜‰
Was this page helpful?