I am using Laravel 6.2 and Maatwebsite/Excel 3.1 here I am trying to import a excel file and willing to get data present in it in an Array format and in the Controller I need to validate some data among them and along with some other fields i need to insert that excel fetched array data to the database. Laravel application has no direct database connection. I am calling an API to insert those fields to the database, but the import operation giving Database connection [] not configured. error. Help me to sort out actual issue from it.
Controller Code
public function importExcelData(Request $request) {
// dd($request->excelFile);
$data = Excel::import(new UsersImport, request()->file('your_file'));
dd($data);
}
UsersImport File
<?php
namespace App\Imports;
use Maatwebsite\Excel\Concerns\ToArray;
class UsersImport implements ToArray
{
public function Array(Array $tables)
{
return $tables;
}
}
?>
After following the error stack appeared in the browser console's network response I got that I can solve this error very easily. as per Laravel Excel Documentation enter link description here we need to run this command in a command prompt
after executing this command 'excel.php' file got created under config folder of the application
in this file , we can found this code
we need to change it as
Now after dumping the import result using dd(), I am seeing those data present in that excel file.