Benjacho / belongs-to-many-field-nova

Belongs To Many field Laravel nova to represent many to many relationship in field.
MIT License
157 stars 80 forks source link

added searchable feature and relatable dependencies feature (to customize options via relatable query) #95

Open jdvrpcre opened 3 years ago

jdvrpcre commented 3 years ago

Hi,

If the related model has lot of records, i added a 'searchable' method which allows you to fetch query dependant options (works the same as 'searchable' for the Nova belongsto field). You can limit the number of results by defining the relatableSearchResults property on the class of the related resource.

I also added a 'debounce' method to control the debounce time for fine tuning.

Note : Lavarel Nova resource 'title' property is set to 'id' by default. I reseted the 'optionLabel' property to 'name' and only used the resource 'title' (which can easily be customized in a nova resource) to resolve options labels. In my opinion, this also avoids passing unnecessary model fields.

Hope you like it.

dalmarcolucas commented 2 years ago

Hey @Benjacho that's a great feature when you have a big list. I think would be nice if you take a look at this PR.

jdvrpcre commented 2 years ago

Hi @Benjacho and @dalmarcolucas, i also added a relatable dependencies feature.

If the options are dependent from other fields values (belongto, select). This method allows you fetch dependent options. You set the array of dependent fields attributes then you can use nova relatableQuery with selectedAttributeName request inputs (available when attribute value is not empty) to customize the options query.

Hope you like it.

imambs commented 2 years ago

It seems a very useful feature, @Benjacho when you can review/merge the PR?

imambs commented 2 years ago

@jdvrpcre it seems this package is abandoned and further progress is here https://github.com/OsTheNeo/NovaFields