Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Scrty's avatar
Level 1

how to save api data to existing database table.

how to save api data to existing database table.

public function delivery_info(Request $request){
        //write codes here
        $params = '';

        $data = array(
            'login'     => 'cargouser',
            'password'  => 'cargouser',
            'db'        => 'digital',
            'domain'    => '[(\'name\',\'=\', \''.$request->job_id.'\')]',
            'fields'    => '[\'delivery_date\',\'branch_id\',\'assigned_to\']',
        ); 

  

        $curl = curl_init();

        curl_setopt_array($curl, array(
          CURLOPT_URL => '/api/delivery',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
          CURLOPT_POSTFIELDS => $data,
          CURLOPT_HTTPHEADER => array(
            'access-token: access_token_0114bc7cdeb37408c9c161d03d4eef93c62a54a0',
            'Cookie: session_id=09d860cd97a45a89fc7c90de17fe50f0672f1c18'
          ),
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        echo $response;
    }
    ```
0 likes
1 reply
Scrty's avatar
Level 1
    {
        Schema::create('feed_back', function (Blueprint $table) {
            $table->increments('id');
            $table->string('JobID',191);
            $table->string('name',191);
            $table->string('mobile',191);
            $table->integer('rating');
            $table->text('message');
            $table->timestamps();
        });
    }```

Please or to participate in this conversation.