Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jukia's avatar
Level 1

how to make status button active and inactive

in laravel

0 likes
3 replies
jukia's avatar
Level 1
$(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) } }); }) })
jukia's avatar
Level 1
          <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');

jukia's avatar
Level 1

please solve my prolem also i have cdn link gaven below

Please or to participate in this conversation.