how make this query in filament php?

Hi how i can replicate this query in filament php?

  CAST(u.id AS CHAR) AS id,
  u.estado,
  u.nombre,
  u.cedula,
  GROUP_CONCAT(DISTINCT ts.ip SEPARATOR '\n ') AS ip,
  GROUP_CONCAT(DISTINCT ts.direccion SEPARATOR '\n ') AS direccion_servicio,
  SUM(
    CASE
      WHEN fa.estado = 'No pagado' THEN fa.total
      ELSE 0
    END
  ) AS deuda_total,
  COUNT(
    CASE
      WHEN fa.estado = 'No pagado' THEN 1
    END
  ) AS cantidad_facturas_no_pagadas,
  GROUP_CONCAT(DISTINCT ts.instalado SEPARATOR '\n ') AS instalado
FROM
  usuarios u
  LEFT JOIN tblservicios ts ON u.id = ts.idcliente
  LEFT JOIN facturas fa ON u.id = fa.idcliente
WHERE
  (
    {{ ! filtroNombre.value }}
    OR u.nombre LIKE {{ '%' + filtroNombre.value + '%' }}
  )
  AND (
    {{filtroEstado.value.length === 0}}
    OR u.estado IN ({{ filtroEstado.value }})
  )
  AND (
    {{ ! filtroCedula.value }}
    OR u.cedula = {{ filtroCedula.value }}
  )
GROUP BY
  u.id,
  u.nombre,
  u.cedula,
  u.direccion_principal;


and show it in a table
Solution
Relationships are Laravel level. You need to understand Eloquent the ORM of Laravel
Was this page helpful?