user(); $size = $request->get('type') == 'avatar' ? 362 : 1024; $result = $uploadTool->save($request->image, str_plural($request['type']), $user->id, $size); $image->path = $result['path']; $image->type = $request['type']; $image->user_id = $user->id; $image->save(); return $this->response->item($image, new ImageTransformer())->setStatusCode(201); } }