app/Http/Controllers/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(UpdateProfileRequest $request, $id)
    {
        $user = User::find($id);
            $user->first_name = $request->input('first_name');
            $user->last_name = $request->input('last_name');
            $user->email = $request->input('email');
            $user->style = $request->input('style');
            $user->show_email = $request->input('show_email');
            $user->landingPage = $request->input('landingPage');
            $user->display = $request->input('display');
            $user->authorFormat = $request->input('authorFormat');
            $user->dateFormat = $request->input('dateFormat');
            $user->rowsPerPage = $request->input('rowsPerPage');
            $user->actionButtons = $request->input('actionButtons');
            $user->alertFadeTime = $request->input('alertFadeTime');
            if ($request->hasFile('image')) {
                $image = $request->file('image');
                $filename = time() . '.' . $image->getClientOriginalExtension();
                $location = public_path('/images/profiles/' . $filename);
                Image::make($image)->resize(800, 400)->save($location);
                $oldImageName = $user->image;
                $user->image = $filename;
                File::delete('images/profiles/' . $oldImageName);
            }
        $user->save();
        Log::info(Auth::user()->username . " (" . Auth::user()->id . ") UPDATED PROFILE\r\n", [json_decode($user, true)]);
        Session::flash ('success', 'The profile was successfully updated!');
        return redirect()->route('profile.show', $user->id);
    }
public function update ( UpdateProfileRequest $ request , $ id ) { $ user = User :: find ( $ id ) ; $ user -> first_name = $ request -> input ( 'first_name' ) ; $ user -> last_name = $ request -> input ( 'last_name' ) ; $ user -> email = $ request -> input ( 'email' ) ; $ user -> style = $ request -> input ( 'style' ) ; $ user -> show_email = $ request -> input ( 'show_email' ) ; $ user -> landingPage = $ request -> input ( 'landingPage' ) ; $ user -> display = $ request -> input ( 'display' ) ; $ user -> authorFormat = $ request -> input ( 'authorFormat' ) ; $ user -> dateFormat = $ request -> input ( 'dateFormat' ) ; $ user -> rowsPerPage = $ request -> input ( 'rowsPerPage' ) ; $ user -> actionButtons = $ request -> input ( 'actionButtons' ) ; $ user -> alertFadeTime = $ request -> input ( 'alertFadeTime' ) ; if ( $ request -> hasFile ( 'image' ) ) { $ image = $ request -> file ( 'image' ) ; $ filename = time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ location = public_path ( '/images/profiles/' . $ filename ) ; Image :: make ( $ image ) -> resize ( 800 , 400 ) -> save ( $ location ) ; $ oldImageName = $ user -> image ; $ user -> image = $ filename ; File :: delete ( 'images/profiles/' . $ oldImageName ) ; } $ user -> save ( ) ; Log :: info ( Auth :: user ( ) -> username . "  ( " . Auth :: user ( ) -> id . " ) UPDATED PROFILE \r \n " , [ json_decode ( $ user , true ) ] ) ; Session :: flash ( 'success' , 'The profile was successfully updated!' ) ; return redirect ( ) -> route ( 'profile.show' , $ user -> id ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
// Get the category value from the database // Save the data to the database // Check if a new image was submitted //Add new photo // get name of old image // Update database // Delete old photo //Storage::delete($oldImageName); // $profile = Profile::where('user_id', '=', Auth::user()->id)->get(); //             //$profile = Profile::where('user_id','=',2); //             //dd($profile); //                 $profile->style = $request->input('style'); //                 $profile->show_email = $request->input('show_email'); //                 $profile->landingPage = $request->input('landingPage'); //                 $profile->display = $request->input('display'); //                 $profile->authorFormat = $request->input('authorFormat'); //                 $profile->dateFormat = $request->input('dateFormat'); //                 $profile->rowsPerPage = $request->input('rowsPerPage'); //                 $profile->actionButtons = $request->input('actionButtons'); //             dd($profile); //             $user->profile->save(); //             //$profile->user->save(); // Save entry to log file using built-in Monolog // Set flash data with success message // Redirect to posts.show