add query param filter has laying

This commit is contained in:
giovanni
2026-02-23 11:46:31 +07:00
parent 5e28721651
commit b73f13ee76
3 changed files with 21 additions and 8 deletions
@@ -60,6 +60,17 @@ func (s locationService) GetAll(c *fiber.Ctx, params *validation.Query) ([]entit
if params.AreaId != 0 {
db = db.Where("area_id = ?", params.AreaId)
}
if params.HasLaying {
db = db.Where(`
EXISTS (
SELECT 1
FROM project_flocks pf
WHERE pf.location_id = locations.id
AND pf.category = ?
AND pf.deleted_at IS NULL
)
`, utils.ProjectFlockCategoryLaying)
}
return db.Order("created_at DESC").Order("updated_at DESC")
})