where('token', $request->header('X-API-TOKEN')) ->first(); $ct->company ->tokens() ->where('is_system', true) ->cursor() ->each(function ($ct){ $ct->token = \Illuminate\Support\Str::random(64); $ct->save(); }); return response()->json(['message' => 'All tokens deleted'], 200); } }