我有一个 excel 文件,我从 excel 构建了一个数组,我需要将数组插入到 laravel 中的数据库中,但 laravel 有错误,我的数组是
private function InsertInDatabase(): void
{
$insertableData = [
['name' => 'joe', 'card_type' => 'mastercard', 'balance' => 100 , 'last_ip'=> '122.154.1.5'],
['name' => 'sara', 'card_type' => 'visa', 'balance' => 10 , 'last_ip'=> '125.194.11.150'],
];
$arrayCount = count($insertableData);
for ( $l = 0; $l <= $arrayCount; $l++ )
{
Database::table($this->dbname)->insert(
$insertableData[$l]
);
}
}
但有错误如何清除此错误
TypeError
Argument 1 passed to Illuminate\Database\Query\Builder::insert() must be of the type array, null given, called in C:\xampp\htdocs\xlsfile\app\Excel\ExcelToDatabase.php on line 99
隔江千里
慕后森
明月笑刀无情
芜湖不芜