createCompanyProcessor = $createCompanyProcessor; $this->updatesCompanyStatus = $updatesCompanyStatus; $this->createCompanyModuleProcessor = $createCompanyModuleProcessor; $this->createContactProcessor = $createContactProcessor; $this->createsCompanyConnection = $createsCompanyConnection; $this->approvesCompanyConnection = $approvesCompanyConnection; $this->createAddressFromOldAddressProcessor = $createAddressFromOldAddressProcessor; $this->createsAddress = $createsAddress; $this->createsCompany = $createsCompany; $this->createsContact = $createsContact; } /** * Run the database seeds. * * @return void * @throws \App\Classes\Exceptions\AccessForbiddenException * @throws \App\Classes\Exceptions\MalformedRequestException * @throws \App\Classes\Exceptions\RequestValidationException */ public function run() { $companies = [ new CompanyObject('CIEF Worldwide Sdn Bhd', 'CIEF', CompanyType::COMPANY_BUSINESS, ApprovalStatus::APPROVED), new CompanyObject('Atvantic Import & Export Sdn Bhd', 'VT-NATION', CompanyType::COMPANY_BUSINESS, ApprovalStatus::APPROVED) ]; foreach ($companies as $companyObject) { /** @var Company $company */ $company = $this->createsCompany->execute($companyObject); if($companyObject->getReference() === 'CIEF') { /** @var CompanyModule $companyModule */ $companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::FREIGHT_FORWARDER); $address = new AddressObject('Malaysian Global Innovation & Creativity Center Level 1 CWS', 'Block 3730,Persiaran APEC', 1, 15, 402, 63000, AddressType::BILLING, ApprovalStatus::APPROVED); $this->createsAddress->execute($companyModule, $address); $contact = new ContactObject('Office Number', '0182909252', '', ''); $this->createsContact->execute($companyModule, $contact); continue; } foreach ([BusinessType::FREIGHT_FORWARDER, BusinessType::WAREHOUSE] as $businessType){ if($businessType === BusinessType::WAREHOUSE){ foreach(['Guangzhou', 'Yiwu', 'Klang', 'Sabah', 'Sarawak'] as $name){ /** @var CompanyModule $companyModule */ $companyModule = $this->createCompanyModuleProcessor->execute($company, $businessType); if ($name === 'Guangzhou'){ $companyModule->update(['name' => $name, 'reference' => 'GZ-V01']); $address = new AddressObject('白云区,大朗南路 白云湖大道自编13号 7号仓库', '高德地图导航:广州市世通行', 2, 35, 633, 510450, AddressType::DELIVERY, ApprovalStatus::APPROVED); $contact = new ContactObject('杨维民', '13600055019', '', ''); } elseif ($name === 'Yiwu') { $companyModule->update(['name' => $name, 'reference' => 'YW-V01']); $address = new AddressObject('义乌市诚信大道义乌港A区2楼194号', '', 2, 27, 532, 322000, AddressType::DELIVERY, ApprovalStatus::APPROVED); $contact = new ContactObject('小曾', '13575982901', '', ''); } elseif ($name === 'Klang') { $companyModule->update(['name' => $name, 'reference' => 'KL-V01']); $address = new AddressObject('LOT 1357 A, JALAN TANJUNG SHAWAL', 'KAMPUNG SUNGAI PINANG', 1, 15, 412, 41400, AddressType::DELIVERY, ApprovalStatus::APPROVED); $contact = new ContactObject('Mr. Yang', '0162237680', '', ''); } elseif ($name === 'Sabah') { $companyModule->update(['name' => $name, 'reference' => 'SB-V01']); $address = new AddressObject('Warehouse A & B, No. 2, Lorong Kacang Tanah 1', 'Jalan Kolombong, Kolombong', 1, 13, 316, 88450, AddressType::DELIVERY, ApprovalStatus::APPROVED); } elseif ($name === 'Sarawak') { $companyModule->update(['name' => $name, 'reference' => 'SRW-V01']); $address = new AddressObject('OPPOSITE HT POLE 51, LT 664 JALAN SUNGAI SALIM', '', 1, 14, 381, 96000, AddressType::DELIVERY, ApprovalStatus::APPROVED); } $this->createsAddress->execute($companyModule, $address); $this->createsContact->execute($companyModule, $contact); } continue; } /** @var CompanyModule $companyModule */ $companyModule = $this->createCompanyModuleProcessor->execute($company, $businessType); $address = new AddressObject('2, Jalan TSB 6, Taman Industri Sungai Buloh', '', 1, 15, 419, 47000, AddressType::BILLING, ApprovalStatus::APPROVED); $this->createsAddress->execute($companyModule, $address); $contact = new ContactObject('Office Number', '036148 8108', '', ''); $this->createsContact->execute($companyModule, $contact); } } // if(true){ // $companies = OldCompany::all(); // // foreach($companies as $company){ // // $marking = explode("CIEF/", $company->marking); // // if(count($marking) < 2){ // continue; // } // // $marking = str_replace(' ', '', str_replace('/', '', $marking[1])); // // // /** @var Company $newCompany */ // $newCompany = $this->createCompanyProcessor->execute($company->name, CompanyType::COMPANY_BUSINESS, ApprovalStatus::PENDING_SUBMISSION); // // $this->updatesCompanyStatus->execute($newCompany, ApprovalStatus::APPROVED); // // /** @var CompanyModule $companyModule */ // $companyModule = $this->createCompanyModuleProcessor->execute($newCompany, BusinessType::IMPORTER); // // $connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', $marking); // // $connection = $this->createsCompanyConnection->execute($connectionObject); // $this->approvesCompanyConnection->execute($connection); // // $i = 0; // foreach($company->addresses as $address){ // $this->createAddressFromOldAddressProcessor->execute($address, $companyModule); // $contact = preg_replace("/[^0-9.]/", "", $address->contact); // if($contact){ // $i++; // if($i === 1) { // $contactObject = new ContactObject('', $contact, $company->email, '',); // $this->createContactProcessor->execute($contactObject, $newCompany); // } // } // // // } // } // } } }