Skip to content

Commit df7089f

Browse files
committed
fix preloading locations for office
1 parent bb28d41 commit df7089f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

controllers/officeController.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ func GetOffices(c *gin.Context) {
105105
}
106106

107107
func GetSingleOffice(c *gin.Context) {
108+
user, _ := c.Get("user")
108109
var office models.Office
109110

110-
result := initializers.DB.Preload("Address").Preload("Locations").Preload("Locations.Status").First(&office, c.Param("id"))
111+
result := initializers.DB.Preload("Address").Preload("Locations", "user_id = ?", user.(models.User).ID).Preload("Locations.Status").First(&office, c.Param("id"))
111112

112113
if result.Error != nil {
113114
c.JSON(http.StatusInternalServerError, gin.H{

0 commit comments

Comments
 (0)