Search code examples
laravelmaatwebsite-excel

Why is this Excel import to my database leaving rows empty while they contain data?


Currently working with Excel and Laravel to import a sheet to my database. The uploading and showing works (yay!) However, I noticed it seems to leave out some columns. The next to last two. The last one gets filled and the one before that does too, so I am curious as to why this does not work as it should.

Database rows:

Table structure:

Excel sheet I am importing (there are more rows but I am limiting it to the troublesome area):

Data import class (this is where I assign the values to the variables):

importeren.blade.php (this is where the importing happens). Reading out the data for each entry using a foreach loop.

As you can see, they are all numeric values, and all of them load fine except for "ADVJaarwerk" and "PeriodiekeADV"

Sidenote: I put char64 because my laravel application demanded me to do so. The tables all run fine except for the specified two. I am honestly wondering why.


Solution

  • Make sure the ADVJaarwerk and PeriodiekeADV attributes are mass assignable in your model:

    protected $fillable = [
        ...
        'ADVJaarwerk',
        'PeriodiekeADV',
        ...
    ];