how to make status button active and inactive
$(function() {
$('.toggle-class').change(function() {
;
var status = $(this).prop('checked') == true ? 1 : 0;
var user_id = $(this).data('data-id');
$.ajax({
type: "GET",
dataType: "json",
url: '/changeStatus',
data: {'status': status, 'user_id': user_id},
success: function(data){
console.log(data.success)
}
});
})
})
<input data-id="{{$entry->id}}" class=" toggle-class "
type="checkbox" style="width: 90.7px!important; height: 35px;"
href="{{ URL::to('changeStatus' ).'?id='.$entry->id}}"
data-onstyle="success" data-offstyle="danger" data-toggle="toggle" data-on="Active" data-off="Inactive" {{ $entry->status ? 'checked' : '' }}>
public function changeStatus(Request $request)
{
// User::where('email', $userEmail)->update({'member_type' => $plan});
$user = User::find($request->id);
// echo $user;
// die();
$user->status = $request->status;
$user->save();
return response()->json(['success'=>'Status change successfully.']);
}
Route::get('changeStatus', [UserData::class, 'changeStatus'])->name('changeStatus');
please solve my prolem also i have cdn link gaven below
Please or to participate in this conversation.