Giter VIP home page Giter VIP logo

Comments (5)

mikebronner avatar mikebronner commented on June 28, 2024 1

@vbezruchkin No problem, I understand. At this time automatically applying default values from configs is not something I am considering, as I believe it to be out of the scope of this package.

Thanks for bringing this up, though! :)

from nova-map-marker-field.

mikebronner avatar mikebronner commented on June 28, 2024

Is this not what you mean?https://github.com/GeneaLabs/nova-map-marker-field#default-settings

from nova-map-marker-field.

vbezruchkin avatar vbezruchkin commented on June 28, 2024

No, I've seen that. But I guess I need to setup this every time I create a field, right?

I might have 10 map fields in different Nova resources. I'd like to have ONE common default settings rather configure default values every time I create a new field. It's like your default 12, and 0/0 for coordinates.

Thanks

from nova-map-marker-field.

mikebronner avatar mikebronner commented on June 28, 2024

I see. You can do this yourself already. Set up a config file, lets say config\settings.php:

return [
    "map_defaults" => [
        "latitude" => "xxxxxxx",
        "longitude" => "xxxxxxx",
        "zoom" => 5,
    ],
];

Then in your nova resources:

MapMarker::make("Location")
    ->defaultZoom(config("settings.map_defaults.zoom"))
    ->defaultLatitude(config("settings.map_defaults.latitude"))
    ->defaultLongitude(config("settings.map_defaults.longitude")),

Those kind of things are very app-dependent, so it's best you handle that as you see fit. I don't want to impose any kind of convention like that, as I have already exposed the functions necessary to let people do what they want. :)

Let me know how that works.

from nova-map-marker-field.

vbezruchkin avatar vbezruchkin commented on June 28, 2024

Thanks for the advice. Yes, this seems reasonable, and I thought of it. But I'd like to go even further.

Let's say we have config file config\mapmarker.php with the following content:

return [
    "map_defaults" => [
        "latitude" => "xxxxxxx",
        "longitude" => "xxxxxxx",
        "zoom" => 5,
    ],
];

and when I create a new Nova field, these settings would be applied automatically for all the resources. This would allow to get rid of default duplication in each resource:

MapMarker::make("Location"),

Not a big deal though, of course I can live with default values in several resource files. But in my case it would be easier to have ONE global settings file, without setting default values in each resource separately.

from nova-map-marker-field.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.