tuseto
tuseto
FFilament
Created by tuseto on 6/21/2024 in #❓┊help
Changing language in ListItem does not translate the related records.
I have a translatable resource with EditResource page. I have some relations to this resource, also translatable. But when I am on the edit page of the resource and change language, the related resources stays listed in english. This is my relation in the form schema:
FieldSet::make('Tags')
->schema([
CheckboxList::make('tags')
->relationship(
titleAttribute: 'name',
)
->columns(5),
])
FieldSet::make('Tags')
->schema([
CheckboxList::make('tags')
->relationship(
titleAttribute: 'name',
)
->columns(5),
])
2 replies
FFilament
Created by tuseto on 4/26/2024 in #❓┊help
Cannot search by table columns with same name but one is from relation
Hello I have a table with 2 columns First is the resource name, second is the related customer name. On both I have used ->searchable() . So If I search by resource name the filter works but it works only for the resource name. Even if you comment out first column name and try to search for customer it will continue search only for the resource name. SQL query does not change at all. Always search in the first column name of the resource. First column name of the resource is json but it think this is irrelevant for the issue. If I change customer.name to customer.phone search starts working as usual for both fields. Any ideas how to fix it?
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('customer.name')
->searchable()
->sortable(),
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('customer.name')
->searchable()
->sortable(),
Bonus Q: how you handle search in json fields, because it differs from normal fields (because of lower) and this can lead to confusion when working with the product.
5 replies
FFilament
Created by tuseto on 3/16/2024 in #❓┊help
How to test list table search in translatable (via spatie) field with pest
I have the following test:
it('can search page by tistle', function () {
$title = Page::first()->title;

$result = livewire(ListPages::class)
->searchTable($title)
->assertCanSeeTableRecords(Page::where('title->en', $title)->get());
});
it('can search page by tistle', function () {
$title = Page::first()->title;

$result = livewire(ListPages::class)
->searchTable($title)
->assertCanSeeTableRecords(Page::where('title->en', $title)->get());
});
So if the first page title is :
{"en": "asdasdas", "es": "spain"}
{"en": "asdasdas", "es": "spain"}
- the test passes but if it is:
{"bg": "Dolores.", "en": "Aut."}
{"bg": "Dolores.", "en": "Aut."}
- the test fails P.S. locale is EN by default Can you help me what is going on? And how to proper test it?
5 replies