I am having a hard time decoding json input in laravel .. am building a Restful API and when i send post data using RestClient and then die and dump in laravel i got
object(Symfony\Component\HttpFoundation\ParameterBag)#205 (1) {
["parameters":protected]=>
array(6) {
["firstName"]=>
string(8) "John"
["lastName"]=>
string(7) "Doe"
["bloodGroup"]=>
string(2) "B+"
["phone"]=>
string(8) "+9999999"
["address"]=>
string(8) "Somecity"
["symptoms"]=>
string(3) "Bla"
}
}
Now i have tied to access the data using
$data = Input::json();
echo $data->firstName;
that does not work .. tried to convert it to array and then access
like $data['firstName']
does not work .
array(1) {
["*parameters"] =>
array(6) {
["firstName"]=>
string(8) "John"
["lastName"]=>
string(7) "Doe"
["bloodGroup"]=>
string(2) "B+"
["phone"]=>
string(8) "+9999999"
["address"]=>
string(8) "Somecity"
["symptoms"]=>
string(3) "Bla"
}
}
i want to decode the data then save it to db, Here is a tutorial building similar App ..
I have tried the post_index() method explained here but no luck .
http://maxoffsky.com/maxoffsky-blog/building-restful-api-in-laravel-part-2-design-api-controller/