mercredi 9 décembre 2020

how to get property from api body in laravel?

I am sending object with API Body Now I need to get One property from that object and I also need to modify that property in the object how I can do this .

Here is my laravel controller function

 public function advanceOrder(Request $request)
    {
        try{
            $result = $request->getContent();
         DB::table('advance_orders')->insert(['data'=> $result]);
        }catch(Exception $e)
        {
            DB::table('advance_orders')->insert(['data'=> $e->getMessage()]);
        }
    }

Here is the object I am getting from api I want to get delivery_datetime property from object and also want to modify property in that object

{"paymethod_id":1,"business_id":76,"delivery_type":1,"driver_tip":0,"delivery_zone_id":6569,"delivery_datetime":"2020-12-09 00:23:00","location":{"lat":18.7675049,"lng":-103.1445221},"deliveryOptionmodal":{"id":2,"value":"Esperar en la entrada","$$hashKey":"object:701"},"delivery_cost_new":20,"products":"[{\"id\":48732,\"code\":\"NLNyEp\",\"quantity\":1,\"options\":[],\"ingredients\":[]}]","customer_id":129731,"customer":"{\"id\":129731,\"name\":\"bil\",\"middle_name\":null,\"lastname\":\"ar\",\"second_lastname\":null,\"photo\":null,\"email\":\"bilal1212@gmail.com\",\"cellphone\":\"0213123132131\",\"address\":\"Coalcomán, Michoacán, Mexico\",\"location\":\"{\\\"lat\\\":18.7675049,\\\"lng\\\":-103.1445221}\",\"internal_number\":null,\"address_notes\":\"sss\",\"zipcode\":null,\"map_data\":{\"library\":\"google\",\"place_id\":\"ChIJz6WGrUw-MIQR_jYIoFZ-RPM\"},\"tag\":\"home\"}"}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire