![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 8 Pomógł: 0 Dołączył: 19.12.2016 Ostrzeżenie: (0%) ![]() ![]() |
Witam, jakiś czas temu zacząłem przygodę z symfony 3.
Napotkałem problem z pobraniem atrybutów klasy "category" w klasie "product" gdy używam klasy subcategory. Jak stworzyć relacje aby można było pobrać atrybut image z category i subcategory w klasie product. klasa category
klasa subcategory
klasa product
setery i getery generowane automatycznie. Klasy są przykładowe. Ten post edytował alfredNN 20.12.2016, 00:18:15 |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 623 Pomógł: 144 Dołączył: 22.12.2010 Ostrzeżenie: (0%) ![]() ![]() |
Pomijając że subcategory mogłoby być typem category (IMG:style_emoticons/default/wink.gif) To masz:
1. Błąd - * @ORM\OneToMany(targetEntity="Sybcategory", mappedBy="category") 2. uzywaj z poziomu konsoli (app|bin)/console doctrine:schema:validate - przy @OneToMany lepiej używaj liczby mnogiej (categories, products, itp) 3. Odpowiadając na pytanie, $product->getSubcategory()->getImage() dla subcategory i $product->getSubcategory()->getCategory()->getImage() |
|
|
![]() ![]() |
![]() |
Aktualny czas: 4.10.2025 - 13:44 |