CodeWithDennis / filament-select-tree

The multi-level select field lets you pick one or multiple options from a list that is neatly organized into different levels.
MIT License
225 stars 32 forks source link

Fixed add withKey method #75

Closed buzkall closed 9 months ago

buzkall commented 9 months ago

In order to specify a different key than the model's one to be the parent key, you can use the ->withKey('name') method.

For example: you have id, code and parent_code in your model. Your model uses id as key, but the parent-child relation is established between code and parent_code In order to make SelectTree work with this model, you need to call the function ->withKey('code')

This PR fixes the problem introduced by https://github.com/CodeWithDennis/filament-select-tree/pull/70 and keeps using the ->getKey() function from the model if no custom key is specified

buzkall commented 9 months ago

Done!

CodeWithDennis commented 9 months ago

Done!

@buzkall Some conflicts!

buzkall commented 9 months ago

Fixed

CodeWithDennis commented 9 months ago

This is breaking every page that uses the SelectTree; Maximum execution time of 30 seconds exceeded

buzkall commented 9 months ago

I'm using it in my local installation and works. I don't know how to replicate the problem you're facing :(

 "codewithdennis/filament-select-tree": "dev-with-key",

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/buzkall/filament-select-tree"
    }
],
CodeWithDennis commented 9 months ago

@buzkall Try to make an example repo with the "normal" way of using the field and you probably will get the same issue.

buzkall commented 9 months ago

I've seen what you meant. I've modified the getCustomKey function to work in both situations