cinsiyet eklenior

This commit is contained in:
merdan 2022-12-21 13:47:50 +05:00
parent 77d84701ec
commit 827ef0f2f3
1 changed files with 5 additions and 5 deletions

View File

@ -26,18 +26,18 @@ func FindOrCreateBrand(db *gorm.DB, brand string, categories []Category) (Brand,
code := slug.Make(brand)
//err := db.Omit("Categories").FirstOrCreate(&brandObject, Brand{Name: brand, Code: code, Categories: categories}).Error
err := db.Model(Brand{Name: brand, Code: code}).First(&brandObject).Error
log.Println(Brand{Name: brand, Code: code})
err := db.Omit("Categories.*").FirstOrCreate(&brandObject, Brand{Name: brand, Code: code, Categories: categories}).Error
//err := db.Model(Brand{Name: brand, Code: code}).First(&brandObject).Error
//log.Println(Brand{Name: brand, Code: code})
if err != nil {
err := db.Omit("Categories.*").FirstOrCreate(&brandObject, Brand{Name: brand, Code: code, Categories: categories}).Error
//err := db.Omit("Categories.*").FirstOrCreate(&brandObject, Brand{Name: brand, Code: code, Categories: categories}).Error
log.Println("ERR0000000000000001" + err.Error())
return brandObject, err
}
log.Println(brandObject)
db.Model(&brandObject).Association("Categories").Append(categories)
//db.Model(&brandObject).Association("Categories").Append(categories)
return brandObject, nil