<?php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass="App\Repository\ProductRepository") * * Warning: Be careful not to use reserved SQL keywords as your table or column * names (e.g. GROUP or USER), Or, configure the table name with the * ORM\Table(name="groups") annotation above the class or configure the column * name with the name="group_name" option. * * Notice: no setId() method. Doctrine sets the ID automatically. */ class Product { /** * The ManyToOne annotation is required to build the relation. * * @ORM\ManyToOne( * targetEntity = "App\Entity\Category", * inversedBy = "products" * ) * @ORM\JoinColumn( * nullable = true * ) */ private $category; /** * @ORM\Column(type="text")) */ private $description; /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=100)) */ private $name; /** * @ORM\Column(type="decimal", scale=2, nullable=true) */ private $price; /** * @return \App\Entity\Category */ public function getCategory(): Category { return $this->category; } /** * @return string */ public function getDescription(): string { return $this->description; } /** * @return int */ public function getId(): int { return $this->id; } /** * @return string */ public function getName(): string { return $this->name; } /** * @return float */ public function getPrice(): float { return $this->price; } /** * @param \App\Entity\Category $category * * @return \App\Entity\Product */ public function setCategory(Category $category): self { $this->category = $category; return $this; } /** * @param string $description * * @return \App\Entity\Product */ public function setDescription(string $description): self { $this->description = $description; return $this; } /** * @param string $name * * @return \App\Entity\Product */ public function setName(string $name): self { $this->name = $name; return $this; } /** * @param float $price * * @return \App\Entity\Product */ public function setPrice(float $price): self { $this->price = $price; return $this; } }