city wise excel import #3923
Unanswered
PriyaTechstas
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?
What version of Laravel Excel are you using?
"maatwebsite/excel": "^3.1",
What version of Laravel are you using?
9
What version of PHP are you using?
8
Describe your issue
city wise excel import how it work out?
public function import(Request $request){
$file = $request->file('file');
$filePath = $file->store('enquiries');
// Step 3: Read the data from the Excel file
$data = Excel::toArray(new EnquiryImport, $filePath);
$groupedData = Excel::groupBy($data[0], 'branch_id');
// Step 5: Store the grouped data in the database branch-wise
foreach ($groupedData as $branch_id => $rows) {
foreach ($rows as $row) {
Enquiry::create([
'name'=> $row[0],
'parent_info_id' => $row[1],
// add more fields as needed
]);
}
is this correct?
How can the issue be reproduced?
public function import(Request $request){
$file = $request->file('file');
$filePath = $file->store('enquiries');
// Step 3: Read the data from the Excel file
$data = Excel::toArray(new EnquiryImport, $filePath);
$groupedData = Excel::groupBy($data[0], 'branch_id');
// Step 5: Store the grouped data in the database branch-wise
foreach ($groupedData as $branch_id => $rows) {
foreach ($rows as $row) {
Enquiry::create([
'name'=> $row[0],
'parent_info_id' => $row[1],
// add more fields as needed
]);
}
What should be the expected behaviour?
public function import(Request $request){
$file = $request->file('file');
$filePath = $file->store('enquiries');
// Step 3: Read the data from the Excel file
$data = Excel::toArray(new EnquiryImport, $filePath);
$groupedData = Excel::groupBy($data[0], 'branch_id');
// Step 5: Store the grouped data in the database branch-wise
foreach ($groupedData as $branch_id => $rows) {
foreach ($rows as $row) {
Enquiry::create([
'name'=> $row[0],
'parent_info_id' => $row[1],
// add more fields as needed
]);
}
Beta Was this translation helpful? Give feedback.
All reactions