cinsiyet eklenior
This commit is contained in:
parent
9745957a1f
commit
b4900a055b
|
|
@ -26,14 +26,20 @@ 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{}).Find(&brandObject,Brand{Name: brand, Code: code, Categories: categories}).Error
|
||||
//err := db.Omit("Categories").FirstOrCreate(&brandObject, Brand{Name: brand, Code: code, Categories: categories}).Error
|
||||
err := db.Model(&Brand{}).Find(&brandObject,Brand{Name: brand, Code: code}).Error
|
||||
|
||||
if err != nil {
|
||||
err := db.Omit("Categories").FirstOrCreate(&brandObject, Brand{Name: brand, Code: code, Categories: categories}).Error
|
||||
log.Println("ERR0000000000000001" + err.Error())
|
||||
return brandObject, err
|
||||
}
|
||||
|
||||
db.Model(&brandObject).Association("Categories").Append(categories)
|
||||
|
||||
return brandObject, nil
|
||||
|
||||
|
||||
}
|
||||
|
||||
// var brandObject Brand
|
||||
|
|
|
|||
Loading…
Reference in New Issue