hello, thank you for your reaction, I use the London Theater API, and currently I have a 2nd problem and the problem is that I can not save this information in the database.
and what is special is that I manage to retrieve and save the other tables without worries.
I have the delivery of the project on Thursday and I am lost.
if you need more info do not hesitate to tell me.
thank you very much.
/*****************here is the code or the problem (in my opinion) ****************************/
@extends('back.layouts.app')
@section('datatableCss')
@endsection
@section('styles')
@endsection
@section('content')
@component('back.components.plain')
@slot('titlePlain')
The Main Configuration Of the web application
@endslot
@slot('sectionPlain')
<table class="table table-bordered table-striped" id="table">
<thead>
<tr>
<th>id</th>
<!-- <th>Image</th> -->
<th>img_url</th>
<th>name</th>
<th>Description</th>
<th>Location</th>
<th>price</th>
<th>Confirm / Delete</th>
</tr>
</thead>
</table>
@endslot
@slot('footerPlain')
@endslot
@endcomponent
@endsection
@section('datatableScript')
@endsection
@section('scripts')
$(function() {
window.exist = JSON.parse('{{ $exist }}');
//rendering table
$('#table').DataTable({
//enjoyer un ajax request avec headers ymkan ngoulk titles mo9dimat bach y3raf ach baghin 7na
ajax: {
timeout: 600000,
//link to get events
"url": "https://api-sandbox.londontheatredirect.com/rest/v2/Events",
//header bach ngolou lou bghina JSON
"contentType": "application/json",
"beforeSend" : function(xhr) {
//header qui contien lkey
//api key
xhr.setRequestHeader('Api-Key','gesjdrynjgev8gqd2rkb6pkz');
},
//'object qui contient les infos'
dataSrc: 'Events',
},
columns: [
//les proprieté de lobject qu'on va mettre dans le tableau
{ data: 'EventId'},
{ data: 'MainImageUrl',
render: function ( data, type, row ) {
return '<img src="'+data+'" width="60px" height="40px" />';
//return 'Img Indisponible';
}
},
// { data: 'MainImageUrl'},
{ data: 'Name'},
{ data: 'Description'},
//"VenueId": 85,//Location Id
{ data: 'VenueId'},
//Mochkila khra bach njabdo limage khasa ndakhlo l array nkhaliwha mn ba3d
// bookable hankhaliwha dima true 7it ma7do t3lan 3lih ya3ni bbokable
{ data: 'OfferPrice'},
{ data: 'EventId',
render: function ( data, type, row ) {
if( $.inArray( Number( data ) , window.exist ) == -1 ){
return '<a href="#" class="btn btn-success btn-confirm" id="'+data+'">Confirm</a>';
}else{
return '<a href="#" class="btn btn-danger btn-delete" id="'+data+'">Delete</a>';
}
}
}
]
});
});
$( document ).ready(function() {
$('#table').on('click','.btn-confirm', function(e){
e.preventDefault();
// btn-confirm id
var id= $(this).attr('id');
var id_selector = $(this);
id_selector.attr('disabled', true);
var slug_parent = id_selector.parent().prev();
var slug = slug_parent.text();
var poster_url_parent = slug_parent.prev();
var poster_url = poster_url_parent.text();
var location_id_parent = poster_url_parent.prev();
var location_id = location_id_parent.text();
var locality_id_parent = location_id_parent.prev();
var locality_id = locality_id_parent.text();
var price_parent = locality_id_parent.prev();
var price = price_parent.text();
axios.post('/shows-post/'+id,{
//csrf token
headers: {
'X-CSRF-TOKEN': $('#csrf-token').attr('content')
},
id: id,
slug: slug,
location_id:location_id,
poster_url:poster_url,
price: price
}).then(function( response ){
//if good
id_selector.attr('disabled', false);
console.log( response.data);
id_selector.removeClass('btn-success btn-confirm');
id_selector.addClass('btn-danger btn-delete');
id_selector.text('Delete');
}).catch(function( error ){
//if error
alert('error');
console.log( error);
id_selector.attr('disabled', false);
});
});
/***********************************/
$('#table').on('click','.btn-delete', function(e){
e.preventDefault();
// btn-confirm id
var id= $(this).attr('id');
var id_selector = $(this);
id_selector.attr('disabled', true);
/* { data: 'Name'},
//Designation
{ data: 'Info'},
{ data: 'Address'},
//localityId
{ data: 'City'},
{ data: 'Postcode'},
//website
{ data: 'Email'},
{ data: 'Telephone'},
{ data: 'VenueId',*/
// debugger;
axios.delete('/shows-delete/'+id,{
//csrf token
headers: {
'X-CSRF-TOKEN': $('#csrf-token').attr('content')
}
}).then(function( response ){
//if good
id_selector.attr('disabled', false);
console.log( response.data);
id_selector.removeClass('btn-danger btn-delete');
id_selector.addClass('btn-success btn-confirm');
id_selector.text('Confirm');
}).catch(function( error ){
//if error
alert('error');
console.log( error);
id_selector.attr('disabled', false);
});
});
});
@endsection