app/Console/Commands/NationalCampany.php
/**
     * Execute the console command.
     *
     * @return int
     */
Execute the console command.
@return int
Execute the console command . @return int
public function handle()
    {
                 $curl = curl_init();
                 curl_setopt_array($curl, array(
                     CURLOPT_URL => "https://taxes.like4app.com/online/check_balance/",
                     CURLOPT_RETURNTRANSFER => true,
                     CURLOPT_ENCODING => "",
                     CURLOPT_MAXREDIRS => 10,
                     CURLOPT_TIMEOUT => 0,
                     CURLOPT_FOLLOWLOCATION => true,
                     CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                     CURLOPT_CUSTOMREQUEST => "POST",
                     CURLOPT_POSTFIELDS => array(
                         'deviceId' => '4d2ec47930a1fe0706836fdd1157a8c320dfc962aa6d0b0df2f4dda40a27b2ba',
                         'email' => 'sales@bn-plus.ly',
                         'password' => '149e7a5dcc2b1946ebf09f6c7684ab2c',
                         'securityCode' => '4d2ec47930a1fe0706836fdd1157a8c36bd079faa0810ff7562c924a23c3f415',
                         'langId' => '1'
                     ),
                 ));
                 $balancenational = curl_exec($curl);
                 if (isset($balancenational) && !empty($balancenational) && $balancenational != 'error code: 1020') {
                     $json = json_decode($balancenational, true);
                     if ($json['balance'] > 0) {
                         $curl2 = curl_init();
                         curl_setopt_array($curl2, array(
                             CURLOPT_URL => "https://taxes.like4app.com/online/categories",
                             CURLOPT_RETURNTRANSFER => true,
                             CURLOPT_ENCODING => "",
                             CURLOPT_MAXREDIRS => 10,
                             CURLOPT_TIMEOUT => 0,
                             CURLOPT_FOLLOWLOCATION => true,
                             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                             CURLOPT_CUSTOMREQUEST => "POST",
                             CURLOPT_POSTFIELDS => array(
                                 'deviceId' => '4d2ec47930a1fe0706836fdd1157a8c320dfc962aa6d0b0df2f4dda40a27b2ba',
                                 'email' => 'sales@bn-plus.ly',
                                 'password' => '149e7a5dcc2b1946ebf09f6c7684ab2c',
                                 'securityCode' => '4d2ec47930a1fe0706836fdd1157a8c36bd079faa0810ff7562c924a23c3f415',
                                 'langId' => '1'
                             ),
                         ));
                         $companiesnational = curl_exec($curl2);
                         $national = json_decode($companiesnational, true);
                         $compsave = new Company;
                         $allcompanyid = array();
                         foreach ($national['data'] as $company) {
                             if (count(Company::where('id', $company['id'])->get()) == 0) {
                                 $compsave->id = $company['id'];
                                 $compsave->company_image = $company['amazonImage'];
                                 $compsave->name = $company['categoryName'];
                                 $compsave->kind = 'national';
                                 $compsave->api = 1;
                                 $compsave->save();
                                 array_push($allcompanyid, $company['id']);
                             }
                             $curl3 = curl_init();
                             curl_setopt_array($curl3, array(
                                 CURLOPT_URL => "https://taxes.like4app.com/online/products",
                                 CURLOPT_RETURNTRANSFER => true,
                                 CURLOPT_ENCODING => "",
                                 CURLOPT_MAXREDIRS => 10,
                                 CURLOPT_TIMEOUT => 0,
                                 CURLOPT_FOLLOWLOCATION => true,
                                 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                                 CURLOPT_CUSTOMREQUEST => "POST",
                                 CURLOPT_POSTFIELDS => array(
                                     'deviceId' => '4d2ec47930a1fe0706836fdd1157a8c320dfc962aa6d0b0df2f4dda40a27b2ba',
                                     'email' => 'sales@bn-plus.ly',
                                     'password' => '149e7a5dcc2b1946ebf09f6c7684ab2c',
                                     'securityCode' => '4d2ec47930a1fe0706836fdd1157a8c36bd079faa0810ff7562c924a23c3f415',
                                     'langId' => '1',
                                     'categoryId'=>$company['id']
                                 ),
                             ));
                             $cardsnational = curl_exec($curl3);
                             $allcards = json_decode($cardsnational, true);
                             $cardsave = new Cards;
                             if (count($allcards) > 0) {
                                 if (isset($allcards['data'])) {
                                     foreach ($allcards['data'] as $card) {
                                         if (count(Cards::where('id', $card['productId'])->get()) == 0) {
                                             if (count(Company::where('id', $card['categoryId'])->get()) != 0) {
                                                 $cardsave->id =  $card['productId'];
                                                 $cardsave->company_id = $card['categoryId'];
                                                 $cardsave->card_name = $card['productName'];
                                                 $cardsave->card_price = $card['productPrice'];
                                                 $cardsave->card_code = $card['productName'];
                                                 $cardsave->card_image = $card['productImage'];
                                                 $cardsave->nationalcompany = 'national';
                                                 $cardsave->api = 1;
                                                 $cardsave->save();
                                                 array_push($allcardsid, $card['productId']);
                                             } else {
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                    $this->info('National Cummand Run successfully!.');
    }
public function handle ( ) { $ curl = curl_init ( ) ; curl_setopt_array ( $ curl , array ( CURLOPT_URL => " https://taxes.like4app.com/online/check_balance/ " , CURLOPT_RETURNTRANSFER => true , CURLOPT_ENCODING => " " , CURLOPT_MAXREDIRS => 10 , CURLOPT_TIMEOUT => 0 , CURLOPT_FOLLOWLOCATION => true , CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1 , CURLOPT_CUSTOMREQUEST => " POST " , CURLOPT_POSTFIELDS => array ( 'deviceId' => '4d2ec47930a1fe0706836fdd1157a8c320dfc962aa6d0b0df2f4dda40a27b2ba' , 'email' => 'sales@bn-plus.ly' , 'password' => '149e7a5dcc2b1946ebf09f6c7684ab2c' , 'securityCode' => '4d2ec47930a1fe0706836fdd1157a8c36bd079faa0810ff7562c924a23c3f415' , 'langId' => '1' ) , ) ) ; $ balancenational = curl_exec ( $ curl ) ; if ( isset ( $ balancenational ) && ! empty ( $ balancenational ) && $ balancenational != 'error code: 1020' ) { $ json = json_decode ( $ balancenational , true ) ; if ( $ json [ 'balance' ] > 0 ) { $ curl2 = curl_init ( ) ; curl_setopt_array ( $ curl2 , array ( CURLOPT_URL => " https://taxes.like4app.com/online/categories " , CURLOPT_RETURNTRANSFER => true , CURLOPT_ENCODING => " " , CURLOPT_MAXREDIRS => 10 , CURLOPT_TIMEOUT => 0 , CURLOPT_FOLLOWLOCATION => true , CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1 , CURLOPT_CUSTOMREQUEST => " POST " , CURLOPT_POSTFIELDS => array ( 'deviceId' => '4d2ec47930a1fe0706836fdd1157a8c320dfc962aa6d0b0df2f4dda40a27b2ba' , 'email' => 'sales@bn-plus.ly' , 'password' => '149e7a5dcc2b1946ebf09f6c7684ab2c' , 'securityCode' => '4d2ec47930a1fe0706836fdd1157a8c36bd079faa0810ff7562c924a23c3f415' , 'langId' => '1' ) , ) ) ; $ companiesnational = curl_exec ( $ curl2 ) ; $ national = json_decode ( $ companiesnational , true ) ; $ compsave = new Company ; $ allcompanyid = array ( ) ; foreach ( $ national [ 'data' ] as $ company ) { if ( count ( Company :: where ( 'id' , $ company [ 'id' ] ) -> get ( ) ) == 0 ) { $ compsave -> id = $ company [ 'id' ] ; $ compsave -> company_image = $ company [ 'amazonImage' ] ; $ compsave -> name = $ company [ 'categoryName' ] ; $ compsave -> kind = 'national' ; $ compsave -> api = 1 ; $ compsave -> save ( ) ; array_push ( $ allcompanyid , $ company [ 'id' ] ) ; } $ curl3 = curl_init ( ) ; curl_setopt_array ( $ curl3 , array ( CURLOPT_URL => " https://taxes.like4app.com/online/products " , CURLOPT_RETURNTRANSFER => true , CURLOPT_ENCODING => " " , CURLOPT_MAXREDIRS => 10 , CURLOPT_TIMEOUT => 0 , CURLOPT_FOLLOWLOCATION => true , CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1 , CURLOPT_CUSTOMREQUEST => " POST " , CURLOPT_POSTFIELDS => array ( 'deviceId' => '4d2ec47930a1fe0706836fdd1157a8c320dfc962aa6d0b0df2f4dda40a27b2ba' , 'email' => 'sales@bn-plus.ly' , 'password' => '149e7a5dcc2b1946ebf09f6c7684ab2c' , 'securityCode' => '4d2ec47930a1fe0706836fdd1157a8c36bd079faa0810ff7562c924a23c3f415' , 'langId' => '1' , 'categoryId' => $ company [ 'id' ] ) , ) ) ; $ cardsnational = curl_exec ( $ curl3 ) ; $ allcards = json_decode ( $ cardsnational , true ) ; $ cardsave = new Cards ; if ( count ( $ allcards ) > 0 ) { if ( isset ( $ allcards [ 'data' ] ) ) { foreach ( $ allcards [ 'data' ] as $ card ) { if ( count ( Cards :: where ( 'id' , $ card [ 'productId' ] ) -> get ( ) ) == 0 ) { if ( count ( Company :: where ( 'id' , $ card [ 'categoryId' ] ) -> get ( ) ) != 0 ) { $ cardsave -> id = $ card [ 'productId' ] ; $ cardsave -> company_id = $ card [ 'categoryId' ] ; $ cardsave -> card_name = $ card [ 'productName' ] ; $ cardsave -> card_price = $ card [ 'productPrice' ] ; $ cardsave -> card_code = $ card [ 'productName' ] ; $ cardsave -> card_image = $ card [ 'productImage' ] ; $ cardsave -> nationalcompany = 'national' ; $ cardsave -> api = 1 ; $ cardsave -> save ( ) ; array_push ( $ allcardsid , $ card [ 'productId' ] ) ; } else { } } } } } } } } $ this -> info ( 'National Cummand Run successfully!.' ) ; }
Execute the console command.
Execute the console command .
/////////////dubi national api //  return $json['balance']; // return($companiesnational); //  return count($allcompanyid); /////////////////cards  // 'ids[]' => $company['id'] // $allcardsid = array(); // return count(Company::where('id', $cards['categoryId'])->get()); //  return $allcardsid ;