simonhamp / laravel-nova-csv-import

The best CSV import component for Laravel Nova
https://novapackages.com/packages/simonhamp/laravel-nova-csv-import
MIT License
166 stars 76 forks source link

Feature: Add modifier for Default Values #62

Closed kevin-dapps closed 1 year ago

kevin-dapps commented 1 year ago

This PR introduces the DefaultValue modifer. This allows you to set a default value for a column only if the value is empty or null without overwriting the value if it is set.

See screenshots below.

Configure Screenshot 2023-04-21 at 14-23-16 Ampersand - Configure Import Modifier image Review Screenshot 2023-04-21 at 14-25-01 Ampersand - Import Preview

simonhamp commented 1 year ago

@kevin-dapps Looks great! Thanks so much for the nice and very useful PR

One thought: Is empty() maybe a little too pervasive? Won't it evaluate to true for anything falsey (e.g. 0 and '0')?

Perhaps it needs to be more explicit, something like $value === null ? ... - what do you think?

I've replicated this branch on my version of the repo and added some updates. Could you update your version of this branch to get those changes into this PR?

kevin-dapps commented 1 year ago

Thank you for all your help! I value your suggestions and feedback. I've pulled your changes in and changed the conditional to be more explicit now. 👍