app/Http/Controllers/UserController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\User  $user
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, User $user)
    {
        $rules = [
            'nama_dpn' => 'required|max:25',
            'nama_blkng' => 'required|max:25',
            'email' => 'required',
            'password' => 'required',
        ];
        if($request->email != $user->email){
            $rules['email'] = 'required|unique:users';
        }
        $validatedData = $request->validate($rules);
        User::where('id', $user->id)
                ->update($validatedData);        
        return redirect('/user')->with('success', 'Berhasil mengubah data!');
    }
public function update ( Request $ request , User $ user ) { $ rules = [ 'nama_dpn' => 'required|max:25' , 'nama_blkng' => 'required|max:25' , 'email' => 'required' , 'password' => 'required' , ] ; if ( $ request -> email != $ user -> email ) { $ rules [ 'email' ] = 'required|unique:users' ; } $ validatedData = $ request -> validate ( $ rules ) ; User :: where ( 'id' , $ user -> id ) -> update ( $ validatedData ) ; return redirect ( '/user' ) -> with ( 'success' , 'Berhasil mengubah data!' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .