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

Preview Route returns 404 #17

Closed acewebsa closed 5 years ago

acewebsa commented 5 years ago

Route::get('/preview/{file}', 'ImportController@preview'); is giving a 404 error. If I do a dd just before the return line it is returned, so it is definitely finding the preview function without issue. Can't work out why this returns 404 though. Any thoughts on why this might be? Not sure if its related to #16 as I have a lot of resources with BelongsTo Fields in the project.

fpcimmino commented 5 years ago

I have the same problem. The variable "fields" passed in the json response is the problem. If you remove it from the response the preview call returns 200, but I don't understand why.

acewebsa commented 5 years ago

Yes you are right. How bizarre. I think I might look deeper for a fix.

fpcimmino commented 5 years ago

Ok, if you find the solution, write it here. I will do the same if I find it first. Thanks.

acewebsa commented 5 years ago

Cheers will do.

acewebsa commented 5 years ago

It's certainly related to #16 When you take the BelongsTo out of $fields, it then succeeds.

acewebsa commented 5 years ago

Added this to the import controller, and it worked. Not real pretty though.

  foreach ($fields as $key => &$field)
        {
            foreach ($field as $k => &$f)
            {
                if (get_class($f) == 'Laravel\Nova\Fields\BelongsTo')
                {
                    unset($fields[$key][$k]);
                }
            }
        }
fpcimmino commented 5 years ago

Thanks for your help.