Level 1
To anyone that in the future has the same problem, the correct way to doit isn't with models, instead you need to use collections: https://docs.laravel-excel.com/3.1/imports/collection.html
namespace App\Imports;
use App\User;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;
class UsersImport implements ToCollection
{
public function collection(Collection $rows)
{
foreach ($rows as $row)
{
User::create([
'name' => $row[0],
]);
}
}
}
´´´
1 like