app/Http/Controllers/Main_Controller/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::find($id);
        if($request->has('newpassword')){
            $user->password=Hash::make($request->newpassword);
        }
        $user->name=$request->name;
        $user->mobile=$request->phone;
        $user->email=$request->email;
        $profileimage=$request->userimage;
        if($request->hasFile('userimage')){
            $profileUserImage = $user->image;
            if($profileUserImage != null){
                $path = 'Media/user_profile/' . $profileUserImage;
                unlink($path);
            }
            $x = 'abcdefghijklmnopqrstuvwxyz0123456789';
            $x = str_shuffle($x);
            $x = substr($x, 0, 6) . '.PI_S.';
            $profileImageFilename = time() . $x . $profileimage->getClientOriginalExtension();
            Image::make($profileimage->getRealPath())->resize(250, 200)->save(public_path('/Media/user_profile/' . $profileImageFilename));
            $user->image=$profileImageFilename;
        }
        $user->save();
        $notification=array(
            'messege'=>'Successfully Profile Updated!',
            'alert-type'=>'success'
        );
        return Redirect()->back()->with($notification);
    }
public function update ( Request $ request , $ id ) { $ user = User :: find ( $ id ) ; if ( $ request -> has ( 'newpassword' ) ) { $ user -> password = Hash :: make ( $ request -> newpassword ) ; } $ user -> name = $ request -> name ; $ user -> mobile = $ request -> phone ; $ user -> email = $ request -> email ; $ profileimage = $ request -> userimage ; if ( $ request -> hasFile ( 'userimage' ) ) { $ profileUserImage = $ user -> image ; if ( $ profileUserImage != null ) { $ path = 'Media/user_profile/' . $ profileUserImage ; unlink ( $ path ) ; } $ x = 'abcdefghijklmnopqrstuvwxyz0123456789' ; $ x = str_shuffle ( $ x ) ; $ x = substr ( $ x , 0 , 6 ) . '.PI_S.' ; $ profileImageFilename = time ( ) . $ x . $ profileimage -> getClientOriginalExtension ( ) ; Image :: make ( $ profileimage -> getRealPath ( ) ) -> resize ( 250 , 200 ) -> save ( public_path ( '/Media/user_profile/' . $ profileImageFilename ) ) ; $ user -> image = $ profileImageFilename ; } $ user -> save ( ) ; $ notification = array ( 'messege' => 'Successfully Profile Updated!' , 'alert-type' => 'success' ) ; return Redirect ( ) -> back ( ) -> with ( $ notification ) ; }
Update the specified resource in storage.
Update the specified resource in storage .