i'am using Laravel in my project so i want to change the status of patient when he take an appointement with doctor , so he can have 3 satuts , Accept , waiting (automatically when the patient choose the date and hour), not accept , the issue i'am facing is when i click on active button nothing change in database.
This is the controller of status:
public function changeStatus(Request $request)
{
$user = rdv::where('IDP', $request->input('IDP'))->get();
if (count($user) > 0) {
if ($user->Etat_de_rdv == en_attente) {
$user->Etat_de_rdv = Accepté;
} else {
$user->Etat_de_rdv = Reservé;
}
$user->Etat_de_rdv = $request->input('status');
$user->save();
return response()->json(['success' => 'Status change successfully.']);
}
}
This is the script :
<script>
$('.toggle-class').change(function () {
var status = $(this).prop('checked') == true ? 'Accepter' : 'Temps charger';
var id = $(this).data('IDP');
console.log(id);
console.log(status);
$.ajax({
type: "get",
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
url: 'changeStatus',
data: {
Etat_de_rdv: status, //Should be like this
IDP: id
},
success: function (data) {
console.log(data.success);
}
});
});
</script>
This is the view witch the doctor see all the appointement ;
<h3> Vos patient :</h3>
@foreach($pat as $lo)
@if ($lo->IDD== $med->ID)
<div class="admin">
<div class="info">
<h3> {{ $lo->Nom_et_prénom }} </h3>
<p>{{ $lo->Numéro_de_téléphone }}</p>
<p>{{ $lo->date}}</p>
<p>{{ $lo->time }}</p>
<input data-id="{{$lo->IPD}}" class="toggle-class" type="checkbox" data-onstyle="success"
data-offstyle="danger" data-toggle="toggle" data-on="Accepter"
data-off="Temps charger" {{ $lo->Etat_de_rdv ? 'checked' : '' }}>
</div>
</div>
@endif
@endforeach
*rdv mean : appointement table *IDP : id of patient
Accepté
or"Accepté"
? in your controller" "
@Vineyroutes/web.php
file please.