/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $findId * @return \Illuminate\Http\Response */ public function update(Request $request, $findId) { $find_node = $this->finds->getById($findId); if (!empty($find_node)) { $input = $request->json()->all(); $user = $request->user(); if (empty($user)) { // Test code in order to test with PostMan requests /*$users = new UserRepository(); $user_node = $users->getUser('*****@*****.**'); $user = new \App\Models\Person(); $user->setNode($user_node);*/ abort('401'); } $images = []; // Check for images, they need special processing before the Neo4j writing is initiated if (!empty($input['object']['photograph'])) { foreach ($input['object']['photograph'] as $image) { if (empty($image['identifier'])) { list($name, $name_small, $width, $height) = $this->processImage($image); $images[] = ['src' => $request->root() . '/uploads/' . $name, 'resized' => $request->root() . '/uploads/' . $name_small, 'width' => $width, 'height' => $height]; } else { $images[] = $image; } } } $input['object']['photograph'] = $images; $input['person'] = ['id' => $user->id]; $find = new FindEvent(); $find->setNode($find_node); try { $find->update($input); return response()->json(['url' => '/finds/' . $findId, 'id' => $findId]); } catch (\Exception $ex) { return response()->json(['error' => $ex->getMessage()], 400); } } else { abort('404'); } }