Open LaravelLover069 opened 2 years ago
Sharing a solution here for all those who attempt to use this package to import CSV or XLS(X) data into a JSON database field:
Use Case: Import cell values (e.g. address details) from CSV or XLS files into destination JSON columns.
Solution: Wrap the array mapping between the database JSON child node and the CSV / XLS column within the following function:
response()->json([ Add array here ])->getData()
Place address code example:
public function model(array $row) { return new Client([ 'name' => $row['client'], 'location' => response()->json([ 'address' => $row['address'], 'street'=> $row['street'], 'house_no'=> $row['house_no'], 'postcode'=> $row['postcode'], 'city'=> $row['city'], 'county'=> $row['county'], 'country'=> $row['country'] ])->getData(), ]);
@anaseqal Would be great to have this somewhere in the readme / documentation as this might be useful for others too.
Sharing a solution here for all those who attempt to use this package to import CSV or XLS(X) data into a JSON database field:
Use Case: Import cell values (e.g. address details) from CSV or XLS files into destination JSON columns.
Solution: Wrap the array mapping between the database JSON child node and the CSV / XLS column within the following function:
Place address code example:
@anaseqal Would be great to have this somewhere in the readme / documentation as this might be useful for others too.