laravel-query-builder
laravel-query-builder copied to clipboard
Query Telescope
the query was completely different and complex, despite bringing the result
query telescope
{
"filter":
{
"cidade.id": "3549805",
"nome": "santa"
}
}
select
"id",
"nome",
"cidade_id",
"bairro_id"
from
"geral"."logradouros"
where
LOWER("geral"."logradouros"."nome") LIKE ? ESCAPE '\' and exists (select * from "geral"."cidades" where "geral"."logradouros"."cidade_id" = "geral"."cidades"."id" and "geral"."cidades"."id" = ' % santa % ') and "geral"."logradouros"."deleted_at" is null order by "geral"."logradouros"."id" asc limit 51
public function index(): JsonResponse
{
$logradouro = Logradouro::select(['id', 'nome', 'cidade_id', 'bairro_id']);
$logradouro = QueryBuilder::for($logradouro);
$logradouro->allowedFilters(
AllowedFilter::exact('id'),
AllowedFilter::partial('nome', null, false),
AllowedFilter::exact('cidade.id'),
AllowedFilter::exact('bairro.id'),
AllowedFilter::scope('keyword'),
);
return response()->json($logradouro->cursorPaginate(50)->withQueryString());
}