Reputation: 13492
This was my first crack at making a PUT request, after making a successful GET I was excited then following a tutorial I get an error that I don't quite understand.
Here is the error
"{"error":{"type":"ErrorException","message":"Undefined property: Symfony\\Component\\HttpFoundation\\ParameterBag::$name","file":"C:\\wamp\\www\\basketball-app-framework\\app\\controllers\\PlayersController.php","line":67}}"
I get that its on line 67
and the property is obviously undefined, but I followed the tutorial and I am not sure how else to write this, or why it's not working like the tutorial. I feel it could be because of mod_rewrite, I had an issue with that, and had to set some things in the apache config file just to make the GET request, so possibly I need to change some things to make the PUT.
Here is the code to PUT data.
public function update($id)
{
$input = Input::json();
$player = Player::find($id);
$player->name = $input->name; // this is line 67
$player->save();
}
again the error occours with $player->name = $input->name;
In my show method when I send a GET
public function show($id)
{
return Player::find($id);
}
Player::find($id);
obviously works
so the $player
variable inside my update shouldnt be causing an issue in accessing the name
attribute, so I am at a loss and hoping someone can help this noob out.
Thanks.
Upvotes: 1
Views: 800
Reputation: 12199
Try the following:
public function update($id)
{
$input = Input::all();
$player = Player::find($id);
$player->name = $input['name'];
$player->save();
}
Or Try this:
public function update($id)
{
$player = Player::find($id);
$player->name = Input::get('name');
$player->save();
}
Upvotes: 1