app/Http/Controllers/UsersController.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)
    {
        $userToupdate = User::find($id);
        if ($userToupdate) {
            if ($request) {
                    $userToupdate->name = $request->name;
                    $userToupdate->sirname = $request->sirname;
                    $userToupdate->email = $request->email;
                    $userToupdate->email_verified_at = $request->email_verified_at;
                    $hashedPassword = Hash::make($request->password);
                    $userToupdate->password =  $hashedPassword;
                    $userToupdate -> save();
            return $userToupdate;
            }else{
                return $request->json([
                    "error" => "the request is null"
                ]);
            }
        }else{
            return $request->json([
                "error" => "the user to update does no exist"
            ]);
        }
    }
public function update ( Request $ request , $ id ) { $ userToupdate = User :: find ( $ id ) ; if ( $ userToupdate ) { if ( $ request ) { $ userToupdate -> name = $ request -> name ; $ userToupdate -> sirname = $ request -> sirname ; $ userToupdate -> email = $ request -> email ; $ userToupdate -> email_verified_at = $ request -> email_verified_at ; $ hashedPassword = Hash :: make ( $ request -> password ) ; $ userToupdate -> password = $ hashedPassword ; $ userToupdate -> save ( ) ; return $ userToupdate ; } else { return $ request -> json ( [ " error " => " the request is null " ] ) ; } } else { return $ request -> json ( [ " error " => " the user to update does no exist " ] ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .
//check if the business to update exists in our database # check if the request body is not null # update that user