app/Http/Controllers/UserController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $input = json_decode($request->getContent(), true);
        $user = $this->userRepository->findOneById($id);
        if(!empty($input['name'])) {
            $user->setName($input['name']);
        }
        if(!empty($input['born'])) {
            $user->setBorn($input['born']);
        }
        $this->entityManager->persist($user);
        $this->entityManager->flush();
        return (new Response())->setContent($user->getId());
    }
public function update ( Request $ request , $ id ) { $ input = json_decode ( $ request -> getContent ( ) , true ) ; $ user = $ this -> userRepository -> findOneById ( $ id ) ; if ( ! empty ( $ input [ 'name' ] ) ) { $ user -> setName ( $ input [ 'name' ] ) ; } if ( ! empty ( $ input [ 'born' ] ) ) { $ user -> setBorn ( $ input [ 'born' ] ) ; } $ this -> entityManager -> persist ( $ user ) ; $ this -> entityManager -> flush ( ) ; return ( new Response ( ) ) -> setContent ( $ user -> getId ( ) ) ; }
Update the specified resource in storage.
Update the specified resource in storage .