UPDATE services as s SET s.payed = (SELECT COUNT(*) FROM services_pay as sp WHERE sp.service_id = s. services_to)
$services = \DB::table('services_to')
->whereRaw('json_contains(categoriesId, \''.$categoryId.'\')')
->where('active', '=', 'Y')
->where('moderate', '=', 'Y')
->where('payed', '!=', 0)