Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form class="form" id="cancelchallenge" method="POST" action="{{action('ChallengeController@cancelChallenge')}}">
- <input type="hidden" name="cancel_challengeid" value="462f2e80-8012-11e9-8b02-65a0a3459d7a">
- <button type="button" class="btn-submit-cancelchallenge">cancel challenge</button>
- </form>
- <form class="form" id="cancelchallenge" method="POST" action="{{action('ChallengeController@cancelChallenge')}}">
- <input type="hidden" name="cancel_challengeid" value="9b9ef9d0-8012-11e9-aa0f-95ff09733e52">
- <button type="button" class="btn-submit-cancelchallenge">cancel challenge</button>
- </form>
- $.ajaxSetup({
- headers: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- }
- });
- $(".btn-submit-cancelchallenge").click(function(e){e.preventDefault();
- var $form = $('#cancelchallenge');
- var cancel_challengeid = $("input[name=cancel_challengeid]").val();
- $.ajax({
- type:'POST',
- url: $form.attr('action'),
- data:{cancel_challengeid:cancel_challengeid},
- success:function(data){
- if(data.successful) {
- toastr.success(data.successful);
- }
- }
- });
- });
- Route::post('cancelChallenge', 'ChallengeController@cancelChallenge');
- public function cancelChallenge(Request $request)
- {
- //Some validation
- $challenge = Challenge::where(['id' => $request->cancel_challengeid,
- 'player1' => Auth::user()->id])->first();
- //DB::beginTransaction();
- //Update a row in the challenges table
- //Insert a row into the transactions table
- //Update a row in the users table
- //Commit transaction
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement