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)
    {
        $data = User::find($id);
        if ($request->file('image') == "") {
          $data->image = $data->image;
        }else{
          $path = 'images';
          $file = $request->file('image');
          $ext = $file->getClientOriginalExtension();
          $fileName = rand(1111,9999).".".$ext;
          $file->move($path,$fileName);
          $data->image = $fileName;
        }
        $data->name = $request->name;
        $data->telp = $request->telp;
        $data->email = $request->email;
        if ($request->new_password == "") {
          $data->password = $data->password;
        }else{
          $data->password = Hash::make($request->new_password);
        }
        $data->role = $request->role;
        $data->update();
        return redirect()->route('users.index');
    }
public function update ( Request $ request , $ id ) { $ data = User :: find ( $ id ) ; if ( $ request -> file ( 'image' ) == " " ) { $ data -> image = $ data -> image ; } else { $ path = 'images' ; $ file = $ request -> file ( 'image' ) ; $ ext = $ file -> getClientOriginalExtension ( ) ; $ fileName = rand ( 1111 , 9999 ) . " . " . $ ext ; $ file -> move ( $ path , $ fileName ) ; $ data -> image = $ fileName ; } $ data -> name = $ request -> name ; $ data -> telp = $ request -> telp ; $ data -> email = $ request -> email ; if ( $ request -> new_password == " " ) { $ data -> password = $ data -> password ; } else { $ data -> password = Hash :: make ( $ request -> new_password ) ; } $ data -> role = $ request -> role ; $ data -> update ( ) ; return redirect ( ) -> route ( 'users.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .