-
Notifications
You must be signed in to change notification settings - Fork 34
Illegal offset type #1
Comments
Thank you for the detailed description of your issues. I just published a new release with the fixes. To get it working, you need to rename
How do you imagine that? Do you want to be able to have different column names in the csv than in the database? |
Fantastic response time, thank you so much! both issues sorted, thank you. Regarding mapping fields. As long as I make a csv template available to users, it is probably fine without mapping. However, I think it would be nice for users to be able to visually define the columns that they are required to populate. Particularly if they are receiving an sql error that they don't understand. The mapping would indicate the correct columns and column names, or they can just select the appropriate column to map to. Import Card is great either way. Cheers, |
I think you're right. With validation configured correctly a user should be able to troubleshoot any issues with their import file. This will work for my situation. One suggestion with the error output could be to make it a little more readable? i.e. instead of outputting the row index then the column that needs attention, it could output something like
Currently this would be output as;
With the heading row ignored then 0 index for the first data row, A user may not understand that 3 is in fact row 5 in their import file. Just a thought. Cheers, |
I didn't find a way yet to modify the validation messages for an array validation (https://laravel.com/docs/5.6/validation#validating-arrays) where I can access the index. But if I don't, I will just do the validation loops (for every row) manually. If you know an easier way, feel free to share. But please continue the discussion in #2 since this is a seperate issue. |
Hi @Sparclex ,
Thanks for the nice card!
However I am having an issue importing to a resource that has a computed field, receive an 'illegal offset type error'. If I comment out the computed field in the resource, everything works as expected.
Error message:
Illegal offset type {"userId":4,"email":"email@email.com","exception":"[object] (ErrorException(code: 0): Illegal offset type at /home/vagrant/websites/shoeboxchristmas/vendor/laravel/nova/src/Fields/Field.php:362)
There also seems to be an issue importing to a 'BelongsTo' field, unless it is not marked as 'required' in the resource. I need this to be a required field though.
Any ideas on fixes or work arounds for these issues?
Also are you considering adding field mapping? That would be really nice.. : )
A sample import file is attached (had to save it as 'xlsx' to attach).
Thank you in advance for any assistance.
This is my resource;
`<?php
namespace App\Nova;
use Laravel\Nova\Fields\ID;
use Illuminate\Http\Request;
use Laravel\Nova\Http\Requests\NovaRequest;
use App\Nova\Metrics\Children;
use App\Nova\Metrics\Donators;
use App\Nova\Metrics\RegisteredShoeBoxes;
use Sparclex\NovaImportCard\NovaImportCard;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;
use Laravel\Nova\Fields\Select;
use Naif\Toggle\Toggle;
use App\School;
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
class Child extends Resource
{
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = 'App\Child';
}
`
child-import-test.xlsx
The text was updated successfully, but these errors were encountered: