How to read the Laravel request data

1

I need to extract what is in request- > itemes

Request {#40 ▼
  #json: null
  #convertedFiles: null
  #userResolver: Closure {#472 ▶}
  #routeResolver: Closure {#480 ▶}
  +attributes: ParameterBag {#42 ▶}
  +request: ParameterBag {#48 ▼
    #parameters: array:1 [▼
      "{"itemes":" => array:1 [▼
        "{"Id":"1","Descripcion":"Correa","Precio":12.95,"Envolver":false},{"Id":"3","Descripcion":"T-Shirt","Precio":5.95,"Envolver":false},{"Id":"4","Descripcion":"Camisa","Precio":65.89,"Envolver":false}" => ""
      ]
    ]
  }
  +query: ParameterBag {#48 ▶}
  +server: ServerBag {#44 ▶}
  +files: FileBag {#45 ▶}
  +cookies: ParameterBag {#43 ▶}
  +headers: HeaderBag {#46 ▶}
  #content: null
  #languages: null
  #charsets: null
  #encodings: null
  #acceptableContentTypes: null
  #pathInfo: "/json"
  #requestUri: "/json?{%22itemes%22:[{%22Id%22:%221%22,%22Descripcion%22:%22Correa%22,%22Precio%22:12.95,%22Envolver%22:false},{%22Id%22:%223%22,%22Descripcion%22:%22T-Shirt%22,%22Precio%22:5.95,%22Envolver%22:false},{%22Id%22:%224%22,%22Descripcion%22:%22Camisa%22,%22Precio%22:65.89,%22Envolver%22:false}],%22total%22:%2284.79%22}"
  #baseUrl: ""
  #basePath: null
  #method: "GET"
  #format: null
  #session: Store {#455 ▶}
  #locale: null
  #defaultLocale: "en"
}
    
asked by Juan Liang 29.12.2017 в 13:59
source

1 answer

2

You can access the data with simple foreach

foreach ($request->itemes as $item) {
        echo $item->id;
        echo $item->descripcion;
        echo $item->precio;
        echo $item->envolver;
    }

The echo is for you to see them, and with that you can manipulate them according to what you need.

    
answered by 09.01.2018 в 03:48