mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-03 18:22:57 +00:00
dev day #79
This commit is contained in:
@@ -30,7 +30,9 @@ func (nc *NavigationController) GetNavigationItems(c *gin.Context) {
|
||||
// Get only top-level items (no parent) that are visible and NOT admin-only
|
||||
if err := nc.DB.Where("parent_id IS NULL AND visible = ? AND requires_admin = ?", true, false).
|
||||
Order("display_order ASC").
|
||||
Preload("Children", "visible = ? AND requires_admin = ?", true, false).
|
||||
Preload("Children", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Where("visible = ? AND requires_admin = ?", true, false).Order("display_order ASC")
|
||||
}).
|
||||
Find(&items).Error; err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch navigation items"})
|
||||
return
|
||||
@@ -63,7 +65,7 @@ func (nc *NavigationController) GetAllNavigationItems(c *gin.Context) {
|
||||
var items []models.NavigationItem
|
||||
|
||||
if err := nc.DB.Where("parent_id IS NULL").
|
||||
Order("display_order ASC").
|
||||
Order("requires_admin ASC, display_order ASC").
|
||||
Preload("Children", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Order("display_order ASC")
|
||||
}).
|
||||
|
||||
Reference in New Issue
Block a user