MilenKo
MilenKo
Explore posts from servers
TLCTuto's Laravel Corner
Created by MilenKo on 10/2/2024 in #💡filament
Spatie Settings with Filament CheckboxList
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 =='
]),
// 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
...
// 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
...
...
$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... 😉
8 replies
FFilament
Created by MilenKo on 9/30/2024 in #❓┊help
Spatie Settings Checkboxlist
Wholly guaccamole... It was my silly mistake of trying to define the input form field as an array, e.g.
// 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 =='
]),
// 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 =='
]),
Must be one of all my attempts to please the array data storing... Once I removed it, I CONFIRM YOUR CODE WORKS !!! Thank you @awcodes you saved me a few more weeks of scratching my head...
27 replies
FFilament
Created by MilenKo on 9/30/2024 in #❓┊help
Spatie Settings Checkboxlist
No description
27 replies
FFilament
Created by MilenKo on 9/30/2024 in #❓┊help
Spatie Settings Checkboxlist
No description
27 replies
TLCTuto's Laravel Corner
Created by MilenKo on 10/2/2024 in #💡filament
Spatie Settings with Filament CheckboxList
No description
8 replies
TLCTuto's Laravel Corner
Created by MilenKo on 10/2/2024 in #💡filament
Spatie Settings with Filament CheckboxList
Thank you in advance. Trying to do and share some good with the Open Source community but this wone seems to be a tough nut to crack. Btw, the Filament + Jetstream - I did it already and the code is in the repo, so now we have 2FA in the user profiles while using Filament 🙂 And there seem to be many useful plugins for a starter pack, but I just can't get on hold of the array<>string type var storing... It definitely has to do something with the casts, but I am not really sure which cast to use and how to pass the proper parameters as most (if not all) casts available in LaravelSettings plugin I've tried but could not make it work as it should..
8 replies
FFilament
Created by mile4841 on 8/27/2024 in #❓┊help
How to order naviation groups
I've moved out by setting a group icon and having sub menu items not having one as it makes more sense for my current project needs. By design filament allows either to have icon on the group but not on the items inside the group, or not to group the items and have an icon for any of the items on their own... It is what it is, I am not keen on modifying the filament code as I will have to deal with updates later and it will be a hassle, so for me this topic is closed now... 😉 (having other issues to tackle 😉 )
14 replies
TLCTuto's Laravel Corner
Created by MilenKo on 10/2/2024 in #💡filament
Spatie Settings with Filament CheckboxList
Hey @tuto1902 Maybe you've had such a need in all the project and have resolved it somehow? I've posted the link to my repo for the full source if that helps... All I need is to store a CheckboxList data of checked boxes to the Settings $site_checkboxlist variable and DB. Defining it as an array type returns an error that I am trying to store sting to an array type variable, defining it as a string returns reverse, so I am buffled for almost a week now and can't figure out what on Earth is happening... No AI so far could help as well 😦
8 replies
FFilament
Created by MilenKo on 9/30/2024 in #❓┊help
Spatie Settings Checkboxlist
@awcodes Well, i would expect it to work as well, however there is an error the minute I switch to array type as it tries to store a string as an array and it does not allow it. I've posted it in the initial comment that switching string to array did not do the work. Here is the error from my previous message:
Cannot assign array to property App\Settings\GeneralSettings::$site_checkboxlist of type ?string
Cannot assign array to property App\Settings\GeneralSettings::$site_checkboxlist of type ?string
I've tried also to switch the type of the checkbox as a collection, however it seems like a method like ->collection() does not exist on the form inputs... Seems like the data passed is a JSON object of type: [ '1' => 'true', '2' => 'false' ] Or some other data sorting, but this should have been considered as a string, but it is actually considered as something strange to me, as I cannot define $site_checkboxlist as array, nor as string... Maybe I should try defining it as a JSON object somehow to test, but I don't find any useful information so far about that in the casts, and i've looked into many LaravelSettings casts to figure out which one should i use and how...
27 replies
FFilament
Created by MilenKo on 9/30/2024 in #❓┊help
Spatie Settings Checkboxlist
Tried to add this cast, but it was able to show the Settings page, but blew an error on storing the data: `php public static function casts(): array { return [ 'site_checkboxlist' => \Spatie\LaravelSettings\SettingsCasts\CollectionCast::class, ]; }
27 replies
TLCTuto's Laravel Corner
Created by MilenKo on 9/13/2024 in #💡filament
Action column Label
I did ask in Filament discord as well as i posted on Filament github issues but I assume it was taken as is that the column of actions does not have an alignment option and I sort of moved on as not worth banging head agains a wall for such a small thing. Maybe it is just me who is stubborn and wanted to figure things out but seems like nobody else ever needed such... It still makes sense to me to have such option as for LTR or RTL we need to be able to move any column text, but seems like only Actions have been excluded from this. Matybe it is a bug afterall or maybe it was a "by design" thing with some other concerns I am not seeing in the bigger picture...
4 replies
FFilament
Created by MilenKo on 9/30/2024 in #❓┊help
Spatie Settings Checkboxlist
The idea is to add an example for all Form inputs so that if anybody needs to combine settings, can simply repurpose the template as they see fit without wondering like me how to add this or that or have the error I am facing with array<>string store.
27 replies
FFilament
Created by MilenKo on 9/30/2024 in #❓┊help
Spatie Settings Checkboxlist
@awcodes Here it is the repo with all it's perks. FYI, so far i only have installed a fresh Filament Admin panel with Laravel 11.x and added Larael Jetstream to improve the user logging experience adding 2FA. On top of that I've installed Filament Spatie Settings plugin and created the shared GeneralSettings.php extending Settings and GeneralSettingsPage.php responsible for the Settings form. Here is the github repo URL; https://github.com/mikemastercorp/filament-starter-kit
27 replies
FFilament
Created by MilenKo on 9/30/2024 in #❓┊help
Spatie Settings Checkboxlist
Sure thing, let me just commit it and will share the link here. It is not much as I said but I agree sometimes looking at pieces of code does not give the full picture.. Thanks anyway 😉
27 replies
FFilament
Created by MilenKo on 9/30/2024 in #❓┊help
Spatie Settings Checkboxlist
Steps to reproduce my "issue": 1. Install filament (I used latest from few days ago) 2. Install Spatie-Settings for filament. 3. Create a migration 4. Create a GeneralSettings settings page that extends the Settings class 5. Create the GeneralSettingsPage in filament/pages to show it to the navigation and inside of this page, try to use CheckboxList with the following code (or similar) 6. Try to store a few checkboxes `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 ==' ]) // set the number of columns to order the list options (equal number of coluns and choices makes them horizonta) ->columns(3), // ->label('') // set an empty label value to hide it
27 replies
FFilament
Created by MilenKo on 9/30/2024 in #❓┊help
Spatie Settings Checkboxlist
There aren't any other modifications to official Filament but the migration, GeneralSettings..php and GeneralSettingsPage.php which I've shared. Here is the migration too in case it helps:
<?php

use Spatie\LaravelSettings\Migrations\SettingsMigration;

return new class extends SettingsMigration
{
public function up(): void
{
$this->migrator->add('general.site_name', 'Default Site Name'); // text input setting
$this->migrator->add('general.site_email', '[email protected]'); // text input with email validation
$this->migrator->add('general.site_select', ''); // select dropdown input
$this->migrator->add('general.site_is_checked', ''); // checkbox input
$this->migrator->add('general.site_is_toggled', ''); // toggle input
$this->migrator->add('general.site_checkboxlist', ''); // checkbox list input
$this->migrator->add('general.site_radio', ''); // radio options input
$this->migrator->add('general.meta_title', 'Default Meta Title'); // text input on another tab
$this->migrator->add('general.meta_description', 'Default Meta Description'); // demo text input for the second tab
}
};
<?php

use Spatie\LaravelSettings\Migrations\SettingsMigration;

return new class extends SettingsMigration
{
public function up(): void
{
$this->migrator->add('general.site_name', 'Default Site Name'); // text input setting
$this->migrator->add('general.site_email', '[email protected]'); // text input with email validation
$this->migrator->add('general.site_select', ''); // select dropdown input
$this->migrator->add('general.site_is_checked', ''); // checkbox input
$this->migrator->add('general.site_is_toggled', ''); // toggle input
$this->migrator->add('general.site_checkboxlist', ''); // checkbox list input
$this->migrator->add('general.site_radio', ''); // radio options input
$this->migrator->add('general.meta_title', 'Default Meta Title'); // text input on another tab
$this->migrator->add('general.meta_description', 'Default Meta Description'); // demo text input for the second tab
}
};
27 replies
FFilament
Created by MilenKo on 9/30/2024 in #❓┊help
Spatie Settings Checkboxlist
One type of cast I've found that can be suitable is ArraySerttingsCast but it requires some parameters and I am having hard time finding those
27 replies
FFilament
Created by MilenKo on 9/30/2024 in #❓┊help
Spatie Settings Checkboxlist
@awcodes Ive read it inside out but I am not really finding any clue as to what type of cast to use for storing an array of data to a single column... The only close example to my need was:
class GeneralSettings extends Settings
{
public string $site_name;

public bool $site_active;

public static function group(): string
{
return 'general';
}

public static function encrypted(): array
{
return [
'site_name'
];
}
}
class GeneralSettings extends Settings
{
public string $site_name;

public bool $site_active;

public static function group(): string
{
return 'general';
}

public static function encrypted(): array
{
return [
'site_name'
];
}
}
However in this example it is using the encrypted() method to encrypt the 'site_name' data
27 replies
FFilament
Created by Stricks on 9/27/2024 in #❓┊help
Trouble with Attach (Detach works)
I aggree more code is needed (unless it is prprietary) but otherwise there are only many GUESSES 🙂
53 replies
FFilament
Created by Stricks on 9/27/2024 in #❓┊help
Trouble with Attach (Detach works)
I mean dd the output you should get from the specific column and see if it even returns a value. Another thing can be if the model does not have the rifht to store the object data (guarder or filable properties are not set on the model)
53 replies