Spatie Translatable - Checkbox list

Greetings to everyone. I am developing a project with Laravel Filament. I am using the "Laravel-translatable" Package in the project. I am saving the data in English and Spanish. The data I saved in the database is shown below. In another section, when I want to show the data I saved before (when I want to show the data I saved with "CheckboxList"), the package names are not visible. I would like to get information from you about this. The second and third images are the section where I save the packages. There are English and Spanish versions. I don't have any problems here. A separate area where I want to show the packages. When I list here with "CheckboxList", the package names do not appear. When I do not use the "Laravel-translatable" package, I do not have any problems. https://stackoverflow.com/questions/79021612/spatie-translatable-checkbox-list
Stack Overflow
Spatie Translatable - Checkbox list
I am developing a project with Laravel Filament. I am using the "Laravel-translatable" Package in the project. I am saving the data in English and Spanish. The data I saved in the databas...
No description
No description
No description
No description
4 Replies
tuto1902
tuto19023mo ago
Thanks. Allow me some time to look into this and I’ll get back to you as soon as I can
Eno7x
Eno7xOP3mo ago
Oh sure. Thank you very much
tuto1902
tuto19023mo ago
Based on your description of the problem, you want to show the contents of the packages table (Package model) in a form using the CheckBoxList, and you are using the Translatable package to automatically transform the packages.name column (JSON) based on the application locale. Try using this in the CheckboxList to get all entries from the Package model. Using pluck will return a key => value array. The value is the first parameter and the key is the second (weird, I know)
public function form(Form $form): Form
{
return $form
->schema([
CheckboxList::make('package_id')->options(fn () => Package::pluck('name', 'id'))
])
}
public function form(Form $form): Form
{
return $form
->schema([
CheckboxList::make('package_id')->options(fn () => Package::pluck('name', 'id'))
])
}
I'm also assuming that the form is for some model that or table with a foreign key pointing to the Packages table.
Eno7x
Eno7xOP3mo ago
Thank you very much :pepelove:
Want results from more Discord servers?
Add your server