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

Not showing rows imported (always defaulting to 0 on 'Review Import' page) #72

Open HeadStudios opened 1 year ago

HeadStudios commented 1 year ago

Hi,

After doing an import it is showing me 0 rows were imported - even though the Contact has been entered correctly.

Image 2023-07-06 at 7 41 28 pm

Video for context: https://share.getcloudapp.com/04uv2xre

Any tips you can recommend for me?

philsturgeon commented 1 year ago

I am having the same problem. Data looks good, then it shows 0 out of 1 imported. Show failures doesn't show anything.

Screenshot 2023-07-11 at 1 42 53 PM Screenshot 2023-07-11 at 1 42 58 PM
philsturgeon commented 1 year ago

Looking at the logs, the config file is:

{
    "original_filename": "GIS Tree Import.csv",
    "uploaded_at": 1689080700,
    "values": null,
    "modifiers": [],
    "meta": {
        "file": "decf23b0c7fe1695a67654c46ad674d1.txt",
        "file_name": "decf23b0c7fe1695a67654c46ad674d1",
        "original_file": "GIS Tree Import.csv",
        "original_file_name": "GIS Tree Import"
    },
    "resource": "units",
    "mappings": {
        "unit_type": "unit_type",
        "coordinates-latitude": "latitude",
        "coordinates-longitude": "longitude",
        "specie": "species",
        "site": "site",
        "supervisor": "supervisor",
        "planted_on": "planted_on"
    }
}

and the failures are:

{
    "total_rows": 1,
    "imported": 0,
    "failures": [
        {
            "row": 2,
            "attribute": "three_words",
            "errors": [
                "validation.required"
            ],
            "values": {
                "unit_type": "tree",
                "coordinates-latitude": 56.530453,
                "coordinates-longitude": -5.982582,
                "specie": 1,
                "site": 1,
                "supervisor": 1,
                "planted_on": "2021-04-13 14:35"
            }
        }
    ],
    "errors": []
}

but thats not showing in the UI.

philsturgeon commented 1 year ago
use App\Nova\Fields\PartOfPointField;

// ...
            PartOfPointField::make('Latitude', 'coordinates', 'latitude')
                ->step('0.000001')
                ->onlyOnForms()
                ->rules('required'),

            PartOfPointField::make('Longitude', 'coordinates', 'longitude')
                ->step('0.000001')
                ->onlyOnForms()
                ->rules('required'),

Then its getting upset those fields dont exist in the database.

   Illuminate\Database\QueryException  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'coordinates-latitude' in 'field list' (SQL: insert into `units` (`unit_type`, `coordinates-latitude`, `coordinates-longitude`, `specie`, `site`, `supervisor`, `planted_on`, `uuid`, `updated_at`, `created_at`) values (tree, 56.530453, -5.982582, 1, 1, 1, 2021-04-13 14:35:00, 999efd75-c97f-46c6-baff-96c7214499f6, 2023-07-11 13:16:02, 2023-07-11 13:16:02)).
simonhamp commented 1 year ago

@HeadStudios @philsturgeon it's going to be most helpful if each of you could provide the full context of the relevant Models, Migrations, and Resources here so that I can see what your DB is looking like and how Nova sees things

Right now I can't tell enough to be able to dig into what's going on here, not without a lot more poking around on my end

simonhamp commented 1 year ago

@philsturgeon you should be able to see errors now with v0.7.0

superuser-me commented 9 months ago

@HeadStudios Off topic!, I'm new to laravel nova, How can we add this custom buttons in nova what it's called? Thank you. CleanShot 2023-11-03 at 06 27 29 PM@2x

HeadStudios commented 4 months ago

Any update on this? I thought I fixed it but it seems I'm back to not being able to import again and getting the same error.

@superuser-me you should be able to use a No va detached action or something along those lines for those buttons

sulfanoaf-samba commented 1 month ago

hi @simonhamp we are facing the same problem with @philsturgeon

somehow after import the csv some data are failure, this is expected but the Show failures button not working

if the Show failures button clicked, on the browser console will display

TypeError: Cannot read properties of undefined (reading 'name')
    at laravel-nova-csv-import:2:32995
    at mo (runtime-core.esm-bundler.js:2918:18)
    at laravel-nova-csv-import:2:32848
    at mo (runtime-core.esm-bundler.js:2897:16)
    at laravel-nova-csv-import:2:31449
    at mo (runtime-core.esm-bundler.js:2918:18)
    at laravel-nova-csv-import:2:31278
    at r (runtime-core.esm-bundler.js:814:13)
    at vo (runtime-core.esm-bundler.js:2966:53)
    at Proxy.<anonymous> (nova-back-navigation:1:1572)

we need to refresh the browser multiple times untul Show failures button works