Skip to content
This repository has been archived by the owner on Oct 17, 2022. It is now read-only.

Better nullable support #46

Open
theianjohnson opened this issue Dec 12, 2020 · 2 comments
Open

Better nullable support #46

theianjohnson opened this issue Dec 12, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@theianjohnson
Copy link

Currently I can allow nullable with

MapMarker::make('Location')
    ->latitude('lat')
    ->longitude('lng')
    ->nullable()
    ->nullValues([0])

But if the map is moved at all it's impossible to re-nullify it, can we get a button to clear or reset the map? In my case the lat/lng is conditional so even accepting 0 as null was a compromise as that is a real lat/lng.

@mikebronner
Copy link
Owner

Hi @theianjohnson, thanks for bringing up that use-case. I will look into it. Will also be happy to accept a PR, if you have the time. :)

@mikebronner mikebronner self-assigned this Dec 12, 2020
@mikebronner mikebronner added the enhancement New feature or request label Dec 12, 2020
@citricguy
Copy link

You could create a Nova Action to re-nullify the field. Not as slick as a button in the editor, but is working for me at the moment.

For example:

    /**
     * Perform the action on the given models.
     *
     * @param  \Laravel\Nova\Fields\ActionFields  $fields
     * @param  \Illuminate\Support\Collection  $models
     * @return mixed
     */
    public function handle(ActionFields $fields, Collection $models)
    {
        foreach ($models as $model) {
            $model->lat = null;
            $model->long = null;
            $model->save();
        }
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants