Our client has a separate system, they want to import from their system to our system via import.
Example template from their system
Below picture is the feature we develop, where the user will import from their system to our system.
The header input indicates which header will be gonna use after uploading te mplate
Before uploading a template
After uploading a template
As you can see from the picture above, the column headers is the row # 3 because we chose 3 as a header.
Controller
$results = Excel::toArray(new TemplateImportCSV, $data['file']);
$array = [];
$selected_header = $data['selected_header'] - 1;
$counter = 0;
foreach($results[0][$selected_header] as $key => $result){
if($result){
$object = new stdClass();
$object->column_header = $result;
$object->column_field = strtolower(str_replace(' ', '_', $result));
$object->selected_accubooks_field = 0 ;
$object->new_field = false;
$object->new_field_error = false;
$object->added_new_field_name = '';
$object->coa_field = false;
$object->coa_field_error = false;
$object->name_exists = false;
$object->selected_coa = '';
array_push($array, $object);
}
}
Import
<?php
namespace AppHttpControllersTemplateCollectionsOthersImports;
// use AppModelsAdjustment;
// use AppModelsAdjustmentCategory;
// use AppModelsEmployee;
// use AppRulesCheckEmployee;
use IlluminateSupportCarbon;
use IlluminateSupportFacadesAuth;
use IlluminateSupportCollection;
use MaatwebsiteExcelConcernsToCollection;
use AppModelsFee;
use IlluminateSupportStr;
use AppModelsChartOfAccount;
use AppModelsProformaEntries;
use AppModelsBilling;
use AppModelsBillingItem;
use AppModelsJournalEntry;
use AppModelsMember;
class TemplateCollectionsOtherImportCSVController implements ToCollection
{
public function collection(Collection $rows)
{
}
}
For example: The file that they will import is around 10,000. As I understand from collections, it will get all the rows then convert it to collections
Now, were having a problem because the request will be drop. Is it possible to get only the row selected from the headers without looping all the data?