SHARE
TWEET

Untitled

a guest Jun 17th, 2019 39 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <form class="form" id="cancelchallenge" method="POST" action="{{action('ChallengeController@cancelChallenge')}}">
  2. <input type="hidden" name="cancel_challengeid" value="462f2e80-8012-11e9-8b02-65a0a3459d7a">
  3. <button type="button" class="btn-submit-cancelchallenge">cancel challenge</button>
  4. </form>
  5.  
  6. <form class="form" id="cancelchallenge" method="POST" action="{{action('ChallengeController@cancelChallenge')}}">
  7. <input type="hidden" name="cancel_challengeid" value="9b9ef9d0-8012-11e9-aa0f-95ff09733e52">
  8. <button type="button" class="btn-submit-cancelchallenge">cancel challenge</button>
  9. </form>
  10.      
  11. $.ajaxSetup({
  12.     headers: {
  13.         'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  14.     }
  15. });
  16.  
  17. $(".btn-submit-cancelchallenge").click(function(e){e.preventDefault();
  18.  
  19.     var $form = $('#cancelchallenge');
  20.     var cancel_challengeid = $("input[name=cancel_challengeid]").val();
  21.  
  22.     $.ajax({
  23.         type:'POST',
  24.     url: $form.attr('action'),
  25.     data:{cancel_challengeid:cancel_challengeid},
  26.  
  27.     success:function(data){
  28.         if(data.successful) {
  29.             toastr.success(data.successful);
  30.         }
  31.     }
  32.     });
  33.  
  34. });
  35.      
  36. Route::post('cancelChallenge', 'ChallengeController@cancelChallenge');
  37.      
  38. public function cancelChallenge(Request $request)
  39.     {
  40.         //Some validation
  41.         $challenge = Challenge::where(['id' => $request->cancel_challengeid,
  42.         'player1' => Auth::user()->id])->first();
  43.         //DB::beginTransaction();
  44.         //Update a row in the challenges table
  45.         //Insert a row into the transactions table
  46.         //Update a row in the users table
  47.         //Commit transaction
  48.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top