Closed kirgy closed 3 years ago
What I'm trying to achieve is to specify a list of options only when certain criteria on the database record are met. For example, for a table of users has a many-to-many relationship to countries;
users
countries
CREATE TABLE `countries` ( `id` bigint(20) unsigned, `name` varchar, `iso_code` varchar, `active` tinyint(1), ) CREATE TABLE `countries_users` ( `id` bigint(20) unsigned, `country_id` bigint(20) unsigned, `user_id` int(10) unsigned, )
I want to filter to only show countries which have an active value of 1 (true).
active
1
Is something like this achievable?
BelongsToManyField::make('Operating Countries', 'countries', \App\Nova\Country::class) ->filter(function($query) { return $query->where('active', '=', true); })
If this is an unsupported feature, it would be useful for me to add this to this repo - if it would be of value.
Actually you have options method that supports a callback function, test it.
What I'm trying to achieve is to specify a list of options only when certain criteria on the database record are met. For example, for a table of
users
has a many-to-many relationship tocountries
;I want to filter to only show countries which have an
active
value of1
(true).Is something like this achievable?
If this is an unsupported feature, it would be useful for me to add this to this repo - if it would be of value.