Im try to import csv file in to DB im using this library Laravel Excel But im have error When im try use dd function im see reading only one line in the csv file, this is a heading rows After this rows im see only null It looks like this
array:4 [
0 => "OS_RAH;N_MARK;ZAV_NOMER;DIAM;N_MISC;DATA_VST;DATA_POV;DATA_NAST_POV;KIL_MISIAC;POP_POK;OST_POK;TIP;KON_POK;DATA_KON_POK;DATA_N_PLOMB;N_PLOMB"
1 => null
2 => null
3 => null
]
If someone knows how to solve this problem, I will be very grateful
this is my code from import file
use Importable;
public function model(array $row)
{
HeadingRowFormatter::default('none');
return new ImportPassportCounter([
'OS_RAH' => $row[0],
'N_MARK' => $row[1],
'ZAV_NOMER' => $row[2],
'DIAM' => $row[3],
'N_MISC' => $row[4],
'DATA_VST' => $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],
]);
}
public function chunkSize(): int
{
return 1000;
}
this is my code im Model file
class ImportPassportCounter extends Model
{
use Notifiable;
protected $table = 'import_passport_counters';
protected $fillable = [
'OS_RAH',
'N_MARK',
'ZAV_NOMER',
'DIAM',
'N_MISK',
'DATA_VST',
'DATA_POV',
'DATA_NAST_POV',
'KIL_MISIAC',
'POP_POK',
'OST_POK',
'TIP',
'KON_POK',
'DATA_KON_POK',
'DATA_N_PLOMB',
'N_PLOMB',
];
}
this is my migration file
Schema::create('import_passport_counters', function (Blueprint $table) {
$table->id();
$table->text('OS_RAH')->nullable();
$table->text('N_MARK')->nullable();
$table->text('ZAV_NOMER')->nullable();
$table->text('DIAM')->nullable();
$table->text('N_MISK')->nullable();
$table->text('DATA_VST')->nullable();
$table->text('DATA_POV')->nullable();
$table->text('DATA_NAST_POV')->nullable();
$table->text('KIL_MISIAC')->nullable();
$table->text('POP_POK')->nullable();
$table->text('OST_POK')->nullable();
$table->text('TIP')->nullable();
$table->text('KON_POK')->nullable();
$table->text('DATA_KON_POK')->nullable();
$table->text('DATA_N_PLOMB')->nullable();
$table->text('N_PLOMB')->nullable();
$table->timestamps();
});
this is my code in Controller
$import = Excel::import(new PassportCounterImport, $request->file('file'));
if ($import)
{
$result['success'] = true;
$result['message'] = 'Success';
return response()->json($result, 200);
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2LNbhBY
via IFTTT
Aucun commentaire:
Enregistrer un commentaire