simonhamp / laravel-nova-csv-import

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

Nova 4. #36

Closed philipbaginski closed 2 years ago

philipbaginski commented 2 years ago

Hi,

Is this package compatible with Laravel Nova 4?

simonhamp commented 2 years ago

There's nothing that should prevent it being installed in Nova 4, but I don't know if it will work though 🤷

I haven't got a reason to purchase a Nova 4 license at the moment and try it out.

Please let me know how you get on 🙂

ali-raza-saleem commented 2 years ago

Nova 4 added abstract function menu() in Tool.php. Since LaravelNovaCsvImport.php extends Tool.php, it necessitates the function's implementation in LaravelNovaCsvImport.php. I will be creating pull request to fix it.

simonhamp commented 2 years ago

@philipbaginski @the-alichemist I've been taking a look at this today... it looks like there's actually a lot more needed than I had hoped as Nova 4 is a fundamental change in the way various parts of Nova work, meaning tools need quite a bit of refactoring. I will open a PR shortly

philipbaginski commented 2 years ago

🙏 Fingers crossed 🤞 for U.

simonhamp commented 2 years ago

@philipbaginski @the-alichemist I've prep'd the feature/nova-4 branch and #37. Please feel free to give this a try.

I've been testing quite a bit today and everything seems to work as expected.

I will likely release this as v0.4.0 in the coming days if I don't hear from either of you.

philipbaginski commented 2 years ago

Trying to install with: composer require simonhamp/laravel-nova-csv-import --with-all-dependencies

, but getting error:

C:\Users\Philip\nova>composer require simonhamp/laravel-nova-csv-import --with-all-dependencies Info from https://repo.packagist.org: #StandWithUkraine Using version ^0.3.0 for simonhamp/laravel-nova-csv-import ./composer.json has been updated Running composer update simonhamp/laravel-nova-csv-import --with-all-dependencies Loading composer repositories with package information Info from https://repo.packagist.org: #StandWithUkraine Updating dependencies Lock file operations: 1 install, 0 updates, 0 removals

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

[RuntimeException] C:\Users\Philip\nova\vendor/simonhamp/laravel-nova-csv-import does not exist and could not be created.

simonhamp commented 2 years ago

Yeah, you'll need to explicitly require the branch as I've not released this yet.

You should change your composer.json require section to have:

"simonhamp/laravel-nova-csv-import": "dev-feature/nova-4",

Then run composer update.

philipbaginski commented 2 years ago

Update in composer.json require section done, and after composer update I have got this:

C:\Users\Philip\nova>composer update Loading composer repositories with package information Info from https://repo.packagist.org: #StandWithUkraine Updating dependencies Nothing to modify in lock file Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 1 install, 0 updates, 0 removals Failed to download simonhamp/laravel-nova-csv-import from dist: C:\Users\Philip\nova\vendor/simonhamp/laravel-nova-csv-import does not exist and could not be created. Now trying to download from source

update [--with WITH] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-dev] [--lock] [--no-install] [--no-autoloader] [--no-scripts] [--no-suggest] [--no-progress] [-w|--with-dependencies] [-W|--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] []...

simonhamp commented 2 years ago

What's the value of your minimum-stability setting in your composer.json (if there is one)?

philipbaginski commented 2 years ago

"minimum-stability": "dev",

simonhamp commented 2 years ago

I've just tried this on a brand new repo on my machine and it works fine - composer is happily able to fetch from GitHub and install the package on the dev-feature/nova-4 branch.

[RuntimeException]
C:\Users\Philip\nova\vendor/simonhamp/laravel-nova-csv-import does not exist and could not be created.

@philipbaginski this sounds like a permissions issue.

Not sure how that's come about, but it shouldn't be anything to do with switching to using this dev branch.

I'm not familiar with Windows permissions any more, but it may be worth checking what they are for this C:\Users\Philip\nova\ folder because it sounds like the composer executable can't create folders in vendor.

Please verify that composer is able to install other packages into this directory and fix any permissions issues before trying again.

philipbaginski commented 2 years ago

I'm able to install other packages. I'm able to install main version of this package for Nova 3, which gives error in Nova 4. But is installed and app works.

simonhamp commented 2 years ago

@philipbaginski The only thing in composer that throws that exception is around folder permissions. Not quite sure why it would be fine for some packages and not others though, unless permissions for that one specific folder have been garbled by something.

Might be worth completely deleting the vendor folder and just trying composer update again.

philipbaginski commented 2 years ago

Magic! It works :-) Package is installed and ready to test it. Thank U :-)

philipbaginski commented 2 years ago

Last question: What kind of formats package is able to import?

philipbaginski commented 2 years ago

Testing with simple data and related data. Simply goes smooth. Getting issue with related data. Having field BelongsTo and in the .csv file column I have a name of related model going to be saved as FK in the table I'm importing data to. And it gives an error.

simonhamp commented 2 years ago

@philipbaginski

Last question: What kind of formats package is able to import?

At the moment, I've only tested with CSV, but the importer can handle many formats.

I'm not sure if what I have so far will do what's needed so I maybe need to do a bit more work on that.

If it doesn't work using different formats, please feel free to open a new issue for that feature request with the details of what you need.

Getting issue with related data.

This is already a separate issue (#5). Please add your comments about this requirement to that thread instead of this Nova 4 thread.

voicecode-bv commented 2 years ago

@simonhamp Thanks for your work! Just needed this for my Nova 4 projects and got it working swiftly. 👍

simonhamp commented 2 years ago

@voicecode-bv thats great to hear!

Given that 3 of us have now successfully installed and used the package, I think this is ready to release.

Here goes! 🚀