| 1 | <?php |
||
| 12 | class Category |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @Column(type="integer") |
||
| 16 | * @Id |
||
| 17 | * @GeneratedValue |
||
| 18 | * |
||
| 19 | * @var int |
||
| 20 | */ |
||
| 21 | protected $id; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @ManyToMany(targetEntity="Product") |
||
| 25 | * @JoinTable(name="category_to_products", |
||
| 26 | * joinColumns={@JoinColumn(name="category_id", referencedColumnName="id")}, |
||
| 27 | * inverseJoinColumns={@JoinColumn(name="product_id", referencedColumnName="id", unique=true)} |
||
| 28 | * ) |
||
| 29 | */ |
||
| 30 | protected $products; |
||
| 31 | |||
| 32 | public function __construct() |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @return int |
||
| 39 | */ |
||
| 40 | public function getId() |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @return Collection|Product[] |
||
| 47 | */ |
||
| 48 | public function getProducts() |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param Product $product |
||
| 55 | * |
||
| 56 | * @return $this |
||
| 57 | */ |
||
| 58 | public function addProduct(Product $product) |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @param Product $product |
||
| 69 | * |
||
| 70 | * @return $this |
||
| 71 | */ |
||
| 72 | public function removeProduct(Product $product) |
||
| 80 | } |
||
| 81 |