I am trying to export/import Excel files from/to the database. For that, I have viewed few tutorials. All show the same way for it. Here are the links.
- https://www.laravelcode.com/post/laravel-8-excel-and-csv-import-export-to-database-using-maatwebsite-excel-with-example
- https://www.itsolutionstuff.com/post/laravel-8-import-export-excel-and-csv-file-tutorialexample.html
And some other.
Exporting excel from the database is working fine. I am getting errors only while importing.
In both tutorials, they showed same way of importing code as shown below
public function model(array $row) {
return new product([
'vendor_id' => $row[0],
'product_name' => $row[1],
'product_price' => $row[2],
'product_model' => $row[3],
'created_at' => $row[4],
'updated_at' => $row[5],
]);
}
It is giving me this error while I am trying to import excel.
Add [vendor_id] to fillable property to allow mass assignment on [App\Models\product].
I try to search about fillable and found some solutions. I tried to apply on it but the error isn't getting resolved. Any idea where I went wrong?
UPDATE
Product Model file code
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class product extends Model {
use HasFactory;
}
productmodel in whichvendor_idcolumn is present.productmodel inapp->models->product.php?