Exemplo n.º 1
0
 public function npGetUnit($id)
 {
     $npunit = NPUnit::where('ref', $id)->get();
     //dd($res);
     $np_unit = [];
     foreach ($npunit as $value) {
         // code...
         array_push($np_unit, ['id' => $value->name, 'text' => $value->name]);
         //$np_unit[$value->ref]=$value->name;
     }
     /*$arr=[
       ['id'=>'0', 'text'=>'1'],
       ['id'=>'1', 'text'=>'2'],
       ['id'=>'2', 'text'=>'3']
       ];*/
     return $np_unit;
 }
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!');
 }