filament-select-tree: [Bug]: Column not found: 1054 Unknown column 'field' in 'field list'

What happened?

I have product model BelongsToMany collections model, Here’s my code : ProductResource

SelectTree::make('collections')
    ->label(__('Collections'))
    ->emptyLabel(__('No results found'))
    ->relationship('collections', 'name', 'parent_id', function ($query) {
        return $query->whereLocale('name', app()->getLocale());
    })
    ->searchable()
    ->withCount(),

After saving the product record, it saves the relationship ids in product_collection, but an error appears :

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'collections' in 'field list'

update
  `products`
set
  `has_variants` = 0,
  `collections` = [ 1,
  2,
  3 ],
  `products`.`updated_at` = 2023 -12 -06 15: 44: 09
where
  `id` = 1

How to reproduce the bug

  1. Setup BelongsToMany relationship
  2. Setup SelectTree as mentioned in the doc
  3. Create / update record on adding relationship ids
  4. Save

Package Version

3.1.14

PHP Version

8.2

Laravel Version

10.x

Which operating systems does with happen with?

Linux

Notes

No response

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

                                SelectTree::make('categories')
                                ->label(__('Category'))
                                ->dehydrated(false)
                                ->relationship('categories', 'name', 'parent_id'),

The solution was to enter the element: ->dehydrated(false) good luck! 😄