我有一个小问题,我需要导入一个Excel文件到数据库中,我的Excel文件中有很多信息,当导入完成时,我有像YYYY-MM-DD这样的日期格式的行,而不是这个日期格式YYYY-MM-DD Im获得一个随机数的值我试图改变数据库中的行的类型,数据库的编码,但这无济于事,有人知道我做错了什么这是我从导入文件中得到的代码
public function model(array $row)
{
return new ImportPassportCounter([
'OS_RAH' => $row[0],
'N_MARK' => $row[1],
'ZAV_NOMER' => $row[2],
'DIAM' => $row[3],
'N_MISK' => $row[4],
'DATA_VST' => \DateTime::createFromFormat('Y-m-d', "$row[5]"),
'DATA_POV' => $row[6],
'DATA_NAST_POV' => $row[7],
'KIL_MISIAC' => $row[8],
'POP_POK' => $row[9],
'OST_POK' => $row[10],
'TIP' => $row[11],
'KON_POK' => $row[12],
'DATA_KON_POK' => $row[13],
'DATA_N_PLOMB' => $row[14],
'N_PLOMB' => $row[15],
]);
}这是我的迁移文件
Schema::create('import_passport_counters', function (Blueprint $table) {
$table->id();
$table->string('OS_RAH')->nullable();
$table->string('N_MARK')->nullable();
$table->string('ZAV_NOMER')->nullable();
$table->string('DIAM')->nullable();
$table->string('N_MISK')->nullable();
$table->text('DATA_VST')->nullable();
$table->text('DATA_POV')->nullable();
$table->text('DATA_NAST_POV')->nullable();
$table->string('KIL_MISIAC')->nullable();
$table->string('POP_POK')->nullable();
$table->string('OST_POK')->nullable();
$table->string('TIP')->nullable();
$table->string('KON_POK')->nullable();
$table->text('DATA_KON_POK')->nullable();
$table->text('DATA_N_PLOMB')->nullable();
$table->string('N_PLOMB')->nullable();
$table->timestamps();
});发布于 2020-05-22 03:00:53
尝试使用碳,如下所示
\Carbon::parse($row[5])->toDateString();https://stackoverflow.com/questions/61941147
复制相似问题