app/Http/Controllers/Backend/MemberController.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)
    {
        $rules = array(
                'id' =>'required',
                'email' =>'required',
                'role' => 'required'
        );
        $validator = Validator::make($request->all(), $rules);
        if ($validator->fails()) return response()->json(array('result'=>false , 'message'=>$validator->errors()->first()));
        $user = User::where('id', $id )->first();
        $user->role = $request->input('role');
        $user->firstName = $request->input('firstName');
        $user->lastName = $request->input('lastName');
        $user->phone = $request->input('phone');
        $user->address = $request->input('address');
        if($user->save())
            return response()->json(array('result'=>true , 'message'=>'success' , 'data'=>$user ));
        return response()->json(array('result'=>false , 'message'=>'update fail.' , 'data'=>$user  ));
    }
public function update ( Request $ request , $ id ) { $ rules = array ( 'id' => 'required' , 'email' => 'required' , 'role' => 'required' ) ; $ validator = Validator :: make ( $ request -> all ( ) , $ rules ) ; if ( $ validator -> fails ( ) ) return response ( ) -> json ( array ( 'result' => false , 'message' => $ validator -> errors ( ) -> first ( ) ) ) ; $ user = User :: where ( 'id' , $ id ) -> first ( ) ; $ user -> role = $ request -> input ( 'role' ) ; $ user -> firstName = $ request -> input ( 'firstName' ) ; $ user -> lastName = $ request -> input ( 'lastName' ) ; $ user -> phone = $ request -> input ( 'phone' ) ; $ user -> address = $ request -> input ( 'address' ) ; if ( $ user -> save ( ) ) return response ( ) -> json ( array ( 'result' => true , 'message' => 'success' , 'data' => $ user ) ) ; return response ( ) -> json ( array ( 'result' => false , 'message' => 'update fail.' , 'data' => $ user ) ) ; }
Update the specified resource in storage.
Update the specified resource in storage .