I am following tutorial http://www.tutorials.kode-blog.com/laravel-5-angularjs-tutorial and I have managed to write the similar method for my controller:
public function update(Request $request, $id) {
$employee = Employee::find($id);
$employee->name = $request->input('name');
//...
$employee->save();
return "Sucess updating user #" . $employee->id;
}
It is thought in tutorial that this code works but in reality var_dump($request->input) gives NULL. So - what $request variable should I use for getting the body of the request? I made var_dump($request) but the structure is unmanageably large. Actually I am suscpicous about this tutorial - do we really need to list all the fields in the standard update procedure?
You can access the input data with:
$input = $request->all();
https://laravel.com/docs/5.2/requests#retrieving-input
However, I've also had to get the input in this manner when using AngularJS $http
module:
$input = file_get_contents('php://input');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With