We're building a restful api which in this case is consumed via an Angular frontend. All works well, but PUT requests are not behaving as expected.
First of all I can't use $request->get('present'); to read the values. And second strings and integers are coming through perfectly, but booleans are not.
For example, we have a resource api/orders in the store method i need to convert the booleans like this:
//controller $order->present = ($request->get('present') == "true")? 1: 0; //model protected $casts = [ 'present' => 'boolean', ... ];
The db(mysql) stores this as tinyint.
But the problem arises when I use a PUT request to update my order model. The $request->get('present') doesn't return any value (but i can log the $request->all() successfully). When using postman this works well.
This is a dump from $request->header():
[2015-10-22 12:04:05] local.INFO: array ( 'content-type' => array ( 0 => 'application/x-www-form-urlencoded', ), 'content-length' => array ( 0 => '393', ), 'host' => array ( 0 => 'apm.dev', ), 'connection' => array ( 0 => 'keep-alive', ), 'pragma' => array ( 0 => 'no-cache', ), 'cache-control' => array ( 0 => 'no-cache', ), 'accept' => array ( 0 => 'application/json', ), 'origin' => array ( 0 => 'http://apm.frontend', ), 'user-agent' => array ( 0 => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36', ), 'referer' => array ( 0 => 'http://apm.frontend/', ), 'accept-encoding' => array ( 0 => 'gzip, deflate, sdch', ), 'accept-language' => array ( 0 => 'en-US,en;q=0.8,nl;q=0.6,fr;q=0.4,de;q=0.2', ), )
I hope that someone has any idea what is going on and possibly a solution. Thanks!
Sign in to participate in this thread!