Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.87 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Shop\ShopBundle\Entity;
  4.  
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7.  
  8. /**
  9.  * Cart
  10.  *
  11.  * @ORM\Table()
  12.  * @ORM\Entity
  13.  */
  14. class Cart
  15. {
  16.     /**
  17.      * @var integer
  18.      *
  19.      * @ORM\Column(name="id", type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      */
  23.     private $id;
  24.  
  25.     /**
  26.      * @var string
  27.      *
  28.      * @ORM\Column(name="name", type="string", length=255)
  29.      */
  30.     private $name;
  31.  
  32.      /**
  33.      * @ORM\OneToMany(targetEntity="Product", mappedBy="category")
  34.      */
  35.     protected $product;
  36.  
  37.     public function __construct()
  38.     {
  39.         $this->product = new ArrayCollection();
  40.     }
  41.  
  42.     /**
  43.      * Get id
  44.      *
  45.      * @return integer
  46.      */
  47.     public function getId()
  48.     {
  49.         return $this->id;
  50.     }
  51.  
  52.     /**
  53.      * Set name
  54.      *
  55.      * @param string $name
  56.      * @return Cart
  57.      */
  58.     public function setName($name)
  59.     {
  60.         $this->name = $name;
  61.  
  62.         return $this;
  63.     }
  64.  
  65.     /**
  66.      * Get name
  67.      *
  68.      * @return string
  69.      */
  70.     public function getName()
  71.     {
  72.         return $this->name;
  73.     }
  74.  
  75.     /**
  76.      * Add product
  77.      *
  78.      * @param \Shop\ShopBundle\Entity\Product $product
  79.      * @return Cart
  80.      */
  81.     public function addProduct(\Shop\ShopBundle\Entity\Product $product)
  82.     {
  83.         $this->product[] = $product;
  84.  
  85.         return $this;
  86.     }
  87.  
  88.     /**
  89.      * Remove product
  90.      *
  91.      * @param \Shop\ShopBundle\Entity\Product $product
  92.      */
  93.     public function removeProduct(\Shop\ShopBundle\Entity\Product $product)
  94.     {
  95.         $this->product->removeElement($product);
  96.     }
  97.  
  98.     /**
  99.      * Get product
  100.      *
  101.      * @return \Doctrine\Common\Collections\Collection
  102.      */
  103.     public function getProduct()
  104.     {
  105.         return $this->product;
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement