SQL unable to update in laravel controller











up vote
1
down vote

favorite












I'm having an issue with saving the current updated inputs into the database using this format.



This database was created to store typeform created values through zapier, but I wanted to make it editable.



Here's a snippet of the code in the blade.php



<div class="col-md-12 p0 ">
<div class="col-md-6 PL0 p0_smresp">
<div class=" form-group "><label for="cilent_email" class="optional">Email</label>
<input type="text" name="cilent_email" id="cilent_email" value="{{$userProfile->cilent_email }}" class="form-control" autocomplete="off" placeholder="email">
</div>
</div>
<div class="col-md-6 PR0 p0_smresp">
<div class=" form-group "><label for="client_country" class="optional">Country</label>
@php $usercountry=explode(" - ",$userProfile->client_country); @endphp
<select name="client_country" id="client_country" value="{{$usercountry[1]}}" class="form-control " aria-required="true">
<option value="" selected="selected">{{$usercountry[1]}}</option>
@foreach ($countries as $country)
<option value="{{ $country->id }}" @if( $usercountry[1] == $country->id) selected @endif>{{ $country->country_name }}</option>
@endforeach
</select>
</div>
</div>
</div>
<div class="col-md-12 p0 ">
<div class=" form-group "><label for="client_accomplishment" class="optional">Accomplishments</label>
<input type="text" name="client_accomplishment" id="client_accomplishment" value="{{$userProfile->client_accomplishment }}" class="form-control" autocomplete="off" >
</div>
</div>
<div class="col-md-12 p0 ">
<div class="col-md-6 PL0 p0_smresp">
<div class=" form-group "><label for="client_firstproj" class="optional">First Project Date</label>
<input type="date" name="client_firstproj" id="client_firstproj" value="{{$userProfile->client_first_project }}" class="form-control" autocomplete="off">
</div>
</div>
<div class="col-md-6 PR0 p0_smresp">
<div class=" form-group "><label for="client_totalproj" class="optional">Total Projects Completed</label>
<input type="text" name="client_totalproj" id="client_totalproj" value="{{$userProfile->client_total_project }}" class="form-control" autocomplete="off">
</div>
</div>
</div>


and this is from the controller



public function profileSave(Request $request, $id){

$userProfile= DB::table('user_profile')
->where('cilent_email',Auth::user()->email)
->first();

$userProfile->cilent_email = $request->cilent_email;
$userProfile->client_country = $request->client_country;
$userProfile->client_accomplishments = $request->client_accomplishments;
$userProfile->client_first_project = $request->client_firstproj;
$userProfile->client_total_project = $request->client_totalproj;
$userProfile->enjoy_design = $request->enjoy_design;
$userProfile->enjoy_manage = $request->enjoy_manage;
$userProfile->enjoy_style = $request->enjoy_style;

$user = User::find(Auth::user()->id);
$user->client_url = $request->client_url;

// dd($user);
if($request->skills)
{
foreach ($request->skills as $skill){
$skills.=$skill.';';
}
$userProfile->client_skills = "a:".count($request->skills).":{".$skills."}";
}
else{
$userProfile->client_skills = '';
}

$userProfile->save();
$user->save();
return redirect()->back()->with('message','Profile Settings Updated');
}


Such that when I submit the form with a newly updated input, the refreshed page would still return the same value as previously.










share|improve this question


























    up vote
    1
    down vote

    favorite












    I'm having an issue with saving the current updated inputs into the database using this format.



    This database was created to store typeform created values through zapier, but I wanted to make it editable.



    Here's a snippet of the code in the blade.php



    <div class="col-md-12 p0 ">
    <div class="col-md-6 PL0 p0_smresp">
    <div class=" form-group "><label for="cilent_email" class="optional">Email</label>
    <input type="text" name="cilent_email" id="cilent_email" value="{{$userProfile->cilent_email }}" class="form-control" autocomplete="off" placeholder="email">
    </div>
    </div>
    <div class="col-md-6 PR0 p0_smresp">
    <div class=" form-group "><label for="client_country" class="optional">Country</label>
    @php $usercountry=explode(" - ",$userProfile->client_country); @endphp
    <select name="client_country" id="client_country" value="{{$usercountry[1]}}" class="form-control " aria-required="true">
    <option value="" selected="selected">{{$usercountry[1]}}</option>
    @foreach ($countries as $country)
    <option value="{{ $country->id }}" @if( $usercountry[1] == $country->id) selected @endif>{{ $country->country_name }}</option>
    @endforeach
    </select>
    </div>
    </div>
    </div>
    <div class="col-md-12 p0 ">
    <div class=" form-group "><label for="client_accomplishment" class="optional">Accomplishments</label>
    <input type="text" name="client_accomplishment" id="client_accomplishment" value="{{$userProfile->client_accomplishment }}" class="form-control" autocomplete="off" >
    </div>
    </div>
    <div class="col-md-12 p0 ">
    <div class="col-md-6 PL0 p0_smresp">
    <div class=" form-group "><label for="client_firstproj" class="optional">First Project Date</label>
    <input type="date" name="client_firstproj" id="client_firstproj" value="{{$userProfile->client_first_project }}" class="form-control" autocomplete="off">
    </div>
    </div>
    <div class="col-md-6 PR0 p0_smresp">
    <div class=" form-group "><label for="client_totalproj" class="optional">Total Projects Completed</label>
    <input type="text" name="client_totalproj" id="client_totalproj" value="{{$userProfile->client_total_project }}" class="form-control" autocomplete="off">
    </div>
    </div>
    </div>


    and this is from the controller



    public function profileSave(Request $request, $id){

    $userProfile= DB::table('user_profile')
    ->where('cilent_email',Auth::user()->email)
    ->first();

    $userProfile->cilent_email = $request->cilent_email;
    $userProfile->client_country = $request->client_country;
    $userProfile->client_accomplishments = $request->client_accomplishments;
    $userProfile->client_first_project = $request->client_firstproj;
    $userProfile->client_total_project = $request->client_totalproj;
    $userProfile->enjoy_design = $request->enjoy_design;
    $userProfile->enjoy_manage = $request->enjoy_manage;
    $userProfile->enjoy_style = $request->enjoy_style;

    $user = User::find(Auth::user()->id);
    $user->client_url = $request->client_url;

    // dd($user);
    if($request->skills)
    {
    foreach ($request->skills as $skill){
    $skills.=$skill.';';
    }
    $userProfile->client_skills = "a:".count($request->skills).":{".$skills."}";
    }
    else{
    $userProfile->client_skills = '';
    }

    $userProfile->save();
    $user->save();
    return redirect()->back()->with('message','Profile Settings Updated');
    }


    Such that when I submit the form with a newly updated input, the refreshed page would still return the same value as previously.










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm having an issue with saving the current updated inputs into the database using this format.



      This database was created to store typeform created values through zapier, but I wanted to make it editable.



      Here's a snippet of the code in the blade.php



      <div class="col-md-12 p0 ">
      <div class="col-md-6 PL0 p0_smresp">
      <div class=" form-group "><label for="cilent_email" class="optional">Email</label>
      <input type="text" name="cilent_email" id="cilent_email" value="{{$userProfile->cilent_email }}" class="form-control" autocomplete="off" placeholder="email">
      </div>
      </div>
      <div class="col-md-6 PR0 p0_smresp">
      <div class=" form-group "><label for="client_country" class="optional">Country</label>
      @php $usercountry=explode(" - ",$userProfile->client_country); @endphp
      <select name="client_country" id="client_country" value="{{$usercountry[1]}}" class="form-control " aria-required="true">
      <option value="" selected="selected">{{$usercountry[1]}}</option>
      @foreach ($countries as $country)
      <option value="{{ $country->id }}" @if( $usercountry[1] == $country->id) selected @endif>{{ $country->country_name }}</option>
      @endforeach
      </select>
      </div>
      </div>
      </div>
      <div class="col-md-12 p0 ">
      <div class=" form-group "><label for="client_accomplishment" class="optional">Accomplishments</label>
      <input type="text" name="client_accomplishment" id="client_accomplishment" value="{{$userProfile->client_accomplishment }}" class="form-control" autocomplete="off" >
      </div>
      </div>
      <div class="col-md-12 p0 ">
      <div class="col-md-6 PL0 p0_smresp">
      <div class=" form-group "><label for="client_firstproj" class="optional">First Project Date</label>
      <input type="date" name="client_firstproj" id="client_firstproj" value="{{$userProfile->client_first_project }}" class="form-control" autocomplete="off">
      </div>
      </div>
      <div class="col-md-6 PR0 p0_smresp">
      <div class=" form-group "><label for="client_totalproj" class="optional">Total Projects Completed</label>
      <input type="text" name="client_totalproj" id="client_totalproj" value="{{$userProfile->client_total_project }}" class="form-control" autocomplete="off">
      </div>
      </div>
      </div>


      and this is from the controller



      public function profileSave(Request $request, $id){

      $userProfile= DB::table('user_profile')
      ->where('cilent_email',Auth::user()->email)
      ->first();

      $userProfile->cilent_email = $request->cilent_email;
      $userProfile->client_country = $request->client_country;
      $userProfile->client_accomplishments = $request->client_accomplishments;
      $userProfile->client_first_project = $request->client_firstproj;
      $userProfile->client_total_project = $request->client_totalproj;
      $userProfile->enjoy_design = $request->enjoy_design;
      $userProfile->enjoy_manage = $request->enjoy_manage;
      $userProfile->enjoy_style = $request->enjoy_style;

      $user = User::find(Auth::user()->id);
      $user->client_url = $request->client_url;

      // dd($user);
      if($request->skills)
      {
      foreach ($request->skills as $skill){
      $skills.=$skill.';';
      }
      $userProfile->client_skills = "a:".count($request->skills).":{".$skills."}";
      }
      else{
      $userProfile->client_skills = '';
      }

      $userProfile->save();
      $user->save();
      return redirect()->back()->with('message','Profile Settings Updated');
      }


      Such that when I submit the form with a newly updated input, the refreshed page would still return the same value as previously.










      share|improve this question













      I'm having an issue with saving the current updated inputs into the database using this format.



      This database was created to store typeform created values through zapier, but I wanted to make it editable.



      Here's a snippet of the code in the blade.php



      <div class="col-md-12 p0 ">
      <div class="col-md-6 PL0 p0_smresp">
      <div class=" form-group "><label for="cilent_email" class="optional">Email</label>
      <input type="text" name="cilent_email" id="cilent_email" value="{{$userProfile->cilent_email }}" class="form-control" autocomplete="off" placeholder="email">
      </div>
      </div>
      <div class="col-md-6 PR0 p0_smresp">
      <div class=" form-group "><label for="client_country" class="optional">Country</label>
      @php $usercountry=explode(" - ",$userProfile->client_country); @endphp
      <select name="client_country" id="client_country" value="{{$usercountry[1]}}" class="form-control " aria-required="true">
      <option value="" selected="selected">{{$usercountry[1]}}</option>
      @foreach ($countries as $country)
      <option value="{{ $country->id }}" @if( $usercountry[1] == $country->id) selected @endif>{{ $country->country_name }}</option>
      @endforeach
      </select>
      </div>
      </div>
      </div>
      <div class="col-md-12 p0 ">
      <div class=" form-group "><label for="client_accomplishment" class="optional">Accomplishments</label>
      <input type="text" name="client_accomplishment" id="client_accomplishment" value="{{$userProfile->client_accomplishment }}" class="form-control" autocomplete="off" >
      </div>
      </div>
      <div class="col-md-12 p0 ">
      <div class="col-md-6 PL0 p0_smresp">
      <div class=" form-group "><label for="client_firstproj" class="optional">First Project Date</label>
      <input type="date" name="client_firstproj" id="client_firstproj" value="{{$userProfile->client_first_project }}" class="form-control" autocomplete="off">
      </div>
      </div>
      <div class="col-md-6 PR0 p0_smresp">
      <div class=" form-group "><label for="client_totalproj" class="optional">Total Projects Completed</label>
      <input type="text" name="client_totalproj" id="client_totalproj" value="{{$userProfile->client_total_project }}" class="form-control" autocomplete="off">
      </div>
      </div>
      </div>


      and this is from the controller



      public function profileSave(Request $request, $id){

      $userProfile= DB::table('user_profile')
      ->where('cilent_email',Auth::user()->email)
      ->first();

      $userProfile->cilent_email = $request->cilent_email;
      $userProfile->client_country = $request->client_country;
      $userProfile->client_accomplishments = $request->client_accomplishments;
      $userProfile->client_first_project = $request->client_firstproj;
      $userProfile->client_total_project = $request->client_totalproj;
      $userProfile->enjoy_design = $request->enjoy_design;
      $userProfile->enjoy_manage = $request->enjoy_manage;
      $userProfile->enjoy_style = $request->enjoy_style;

      $user = User::find(Auth::user()->id);
      $user->client_url = $request->client_url;

      // dd($user);
      if($request->skills)
      {
      foreach ($request->skills as $skill){
      $skills.=$skill.';';
      }
      $userProfile->client_skills = "a:".count($request->skills).":{".$skills."}";
      }
      else{
      $userProfile->client_skills = '';
      }

      $userProfile->save();
      $user->save();
      return redirect()->back()->with('message','Profile Settings Updated');
      }


      Such that when I submit the form with a newly updated input, the refreshed page would still return the same value as previously.







      mysql laravel






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 at 7:22









      Monomoni

      5319




      5319
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          $id is return the old value. $input contains the updated value. and include use IlluminateSupportFacadesInput for Input::all()



          $input = Input::all();

          $id->update($input);





          share|improve this answer




























            up vote
            0
            down vote













            Use the userProfile model



            $userProfile= UserProfile::where('cilent_email',Auth::user()->email)->first(); 


            and instant of



            return redirect()->back()->with('message','Profile Settings Updated');
            use return redirect(url('your url'));






            share|improve this answer





















              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388086%2fsql-unable-to-update-in-laravel-controller%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              0
              down vote













              $id is return the old value. $input contains the updated value. and include use IlluminateSupportFacadesInput for Input::all()



              $input = Input::all();

              $id->update($input);





              share|improve this answer

























                up vote
                0
                down vote













                $id is return the old value. $input contains the updated value. and include use IlluminateSupportFacadesInput for Input::all()



                $input = Input::all();

                $id->update($input);





                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  $id is return the old value. $input contains the updated value. and include use IlluminateSupportFacadesInput for Input::all()



                  $input = Input::all();

                  $id->update($input);





                  share|improve this answer












                  $id is return the old value. $input contains the updated value. and include use IlluminateSupportFacadesInput for Input::all()



                  $input = Input::all();

                  $id->update($input);






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 20 at 7:32









                  Bhoomi patel

                  23613




                  23613
























                      up vote
                      0
                      down vote













                      Use the userProfile model



                      $userProfile= UserProfile::where('cilent_email',Auth::user()->email)->first(); 


                      and instant of



                      return redirect()->back()->with('message','Profile Settings Updated');
                      use return redirect(url('your url'));






                      share|improve this answer

























                        up vote
                        0
                        down vote













                        Use the userProfile model



                        $userProfile= UserProfile::where('cilent_email',Auth::user()->email)->first(); 


                        and instant of



                        return redirect()->back()->with('message','Profile Settings Updated');
                        use return redirect(url('your url'));






                        share|improve this answer























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          Use the userProfile model



                          $userProfile= UserProfile::where('cilent_email',Auth::user()->email)->first(); 


                          and instant of



                          return redirect()->back()->with('message','Profile Settings Updated');
                          use return redirect(url('your url'));






                          share|improve this answer












                          Use the userProfile model



                          $userProfile= UserProfile::where('cilent_email',Auth::user()->email)->first(); 


                          and instant of



                          return redirect()->back()->with('message','Profile Settings Updated');
                          use return redirect(url('your url'));







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 20 at 7:49









                          Tarun Saini

                          753




                          753






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388086%2fsql-unable-to-update-in-laravel-controller%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              404 Error Contact Form 7 ajax form submitting

                              How to know if a Active Directory user can login interactively

                              Refactoring coordinates for Minecraft Pi buildings written in Python