title: Update a column when a button is clicked Laravel
body: <p>I am doing a project in laravel and i want to change a value of a column from 0 to 1 when a button is clicked. </p>
  
  <p>i am using ajax to do this.</p>
  
  <p>view.blade</p>
  
  <pre><code> &lt;td&gt;&lt;button type="button" class="btn btn-primary" id="j-approve-user" onclick="approveLogin('{{ route('approve', $user-&gt;id) }}')"&gt;Approve&lt;/button&gt;&lt;/td&gt;
  </code></pre>
  
  <p>ajax script:</p>
  
  <pre><code>let getToken = function() {
  return $('meta[name=csrf-token]').attr('content')
   }
  
  function approveLogin(url){
  let data = { '_token': getToken() }
  
  $.ajax({
      'url': url,
      'method': 'POST',
      'data': data,
  }).done(function(response) {
      //window.location.reload()
  })
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>   public function approve($user_id)
     {
       $user = User::find($user_id);
       $user-&gt;update(['loginapproval'=&gt;'1']);
       return "ok"; 
     }
  </code></pre>
  
  <p>However, i am getting a status code of 500 when i click the button.</p>
  
  <p>Can anyone please help?</p>