app/Http/Controllers/Admin/ProfileController.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);
        $user->update($request->all());
        if(request()->hasFile('avatar')){
            $avatar = $request->file('avatar');
            $filename = time() . '.' . $avatar->getClientOriginalExtension();
            Image::make($avatar)->resize(300,300)->save( public_path('assets/avatars/' . $filename ) );
            $user = Auth::user();
            File::delete('public/assets/avatars/' . $user->avatar );
            $user->avatar = $filename;
            $user->save();
        }
        notify()->success("User $user->name profile updated!");
        return redirect()->route('admin.dashboard');
    }
public function update ( Request $ request , $ id ) { $ user = User :: find ( $ id ) ; $ user -> update ( $ request -> all ( ) ) ; if ( request ( ) -> hasFile ( 'avatar' ) ) { $ avatar = $ request -> file ( 'avatar' ) ; $ filename = time ( ) . '.' . $ avatar -> getClientOriginalExtension ( ) ; Image :: make ( $ avatar ) -> resize ( 300 , 300 ) -> save ( public_path ( 'assets/avatars/' . $ filename ) ) ; $ user = Auth :: user ( ) ; File :: delete ( 'public/assets/avatars/' . $ user -> avatar ) ; $ user -> avatar = $ filename ; $ user -> save ( ) ; } notify ( ) -> success ( " User  $ user -> name  profile updated! " ) ; return redirect ( ) -> route ( 'admin.dashboard' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
// delete old Avatar