make the variable as string in laravel

  http, laravel, php

how are you ?

I’m using Guzzle to send post method but when i tried to send the post method with variable getting error so i tried to convert it to sting but still same

this is my current code

$user = Auth::user();
    $mobile = $user->mobile;
    $client = new Client();
    $booking = Booking::where('id', '=', e($id))->first();
    if($booking)
    {
        $booking->booking_status_id = 3;
        $booking->save();
        $client = new Client([
            'headers' => [ 'Content-Type' => 'application/json' ]
            ]);
            
                  
        $data = array('userName' => "test",
                    'apiKey' => "1",
                    'numbers' => "{$mobile}",
                    'userSender' => "sender",
                    'msg' =>'msg',
                    'msgEncoding' => "UTF8",);
        $dataJson = json_encode($data);         
        $response = $client->post('https://www.test.test',
            ['body' => $dataJson]
        );

Source: Laravel

Leave a Reply