Exemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function npSync()
 {
     Config::setApiKey(Setting::get('integration.np'));
     $unitArr = Address::getWarehouses();
     $adrArr = Address::getCities();
     NPCity::truncate();
     NPUnit::truncate();
     foreach ($adrArr->data as $value) {
         NPCity::create(['name' => $value->DescriptionRu, 'ref' => $value->Ref]);
     }
     foreach ($unitArr->data as $value) {
         NPUnit::create(['name' => $value->DescriptionRu, 'ref' => $value->CityRef]);
     }
 }
Exemplo n.º 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //
     Config::setApiKey(Setting::get('integration.np'));
     NPCity::truncate();
     $this->info('NP City table cleared');
     NPUnit::truncate();
     $this->info('NP Unit table cleared');
     $unitArr = Address::getWarehouses();
     $this->info('NP unit fetched');
     $adrArr = Address::getCities();
     $this->info('NP city fethed');
     foreach ($adrArr->data as $value) {
         NPCity::create(['name' => $value->DescriptionRu, 'ref' => $value->Ref]);
     }
     $this->info('City table filled.');
     foreach ($unitArr->data as $value) {
         NPUnit::create(['name' => $value->DescriptionRu, 'ref' => $value->CityRef]);
     }
     $this->info('Units table filled');
     $this->info('NP SYNC SUCCESSFULL!');
 }