Hallo i get a trouble when i want to import excel with another data in mysql.
This is the controller
public function upload(Request $request){
$file = $request->filebabp;
if($file) {
$nama_file = Carbon::now()->setTimezone('Asia/Jakarta')->format('Ymd-His').'-'.$file->getClientOriginalName();
$datasubmit['file'] = $file;
$datasubmit['upload_date'] = Carbon::now()->setTimezone('Europe/Belarusia')->format('Y-m-d H:i:s');
$datasubmit['nama_file'] = $nama_file;
$datasubmit['version'] = 'NEW';
$file->move(public_path('files/'), $nama_file);
$upload = Excel::import(new TargetUpload($datasubmit), base_path('public/files/'.$nama_file));
}
return $this->sendResponse($file, 'Submit successfully');
}
And this is the Import Multiple Sheet
use Importable;
// /**
// * @param array $row
// *
// * @return IlluminateDatabaseEloquentModel|null
// */
protected $data;
function __construct($data) {
$this->data = $data;
}
public function sheets($data): array
{
return [
0 => new TargetHeaderImport($data),
];
}
I want sending the datasubmit to Import multiple sheet, and i just get a error in this.
If i import on direct ‘TargetHeaderImport’ its safe, but in excel i have a 2 sheets and i just only want one sheet to import.
or do you have a another script to send the ‘submitdata’ ?