This commit is contained in:
James Cole
2019-08-21 05:15:47 +02:00
parent ecc37b2ed3
commit 21a9e981a2
6 changed files with 109 additions and 29 deletions

View File

@@ -226,7 +226,14 @@ class PiggyBankController extends Controller
*/
public function update(PiggyBankRequest $request, PiggyBank $piggyBank): JsonResponse
{
$piggyBank = $this->repository->update($piggyBank, $request->getAll());
$data = $request->getAll();
$piggyBank = $this->repository->update($piggyBank, $data);
if ('' !== $data['current_amount']) {
$this->repository->setCurrentAmount($piggyBank, $data['current_amount']);
}
$manager = new Manager();
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
$manager->setSerializer(new JsonApiSerializer($baseUrl));