app/Http/Controllers/API/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)
    {
        $user = User::findOrfail($id);
        $this->validate($request, [
            'name'     => 'required|string|max:191',
            'email'    => 'required|string|email|max:191|unique:users,email,' . $user->id,
            'password' => 'sometimes|min:6'
        ]);
        $user->update($request->all());
        return ['message' => 'Update the user info'];
    }
public function update ( Request $ request , $ id ) { $ user = User :: findOrfail ( $ id ) ; $ this -> validate ( $ request , [ 'name' => 'required|string|max:191' , 'email' => 'required|string|email|max:191|unique:users,email,' . $ user -> id , 'password' => 'sometimes|min:6' ] ) ; $ user -> update ( $ request -> all ( ) ) ; return [ 'message' => 'Update the user info' ] ; }
Update the specified resource in storage.
Update the specified resource in storage .
// sometimes là khi sửa password nó mới validation