classes/XLite/Model/Membership.php line 49

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved.
  4.  * See https://www.x-cart.com/license-agreement.html for license details.
  5.  */
  6. namespace XLite\Model;
  7. use ApiPlatform\Core\Annotation as ApiPlatform;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use XLite\API\Endpoint\Membership\DTO\MembershipInput;
  10. use XLite\API\Endpoint\Membership\DTO\MembershipOutput;
  11. use XLite\API\Filter\AlphabeticalOrderFilter;
  12. /**
  13.  * Membership
  14.  *
  15.  * @ORM\Entity
  16.  * @ORM\Table (name="memberships")
  17.  * @ApiPlatform\ApiResource(
  18.  *     input=MembershipInput::class,
  19.  *     output=MembershipOutput::class,
  20.  *     itemOperations={
  21.  *         "get"={
  22.  *             "method"="GET",
  23.  *             "path"="/memberships/{membership_id}",
  24.  *             "identifiers"={"membership_id"},
  25.  *         },
  26.  *         "put"={
  27.  *             "method"="PUT",
  28.  *             "path"="/memberships/{membership_id}",
  29.  *             "identifiers"={"membership_id"},
  30.  *         },
  31.  *         "delete"={
  32.  *             "method"="DELETE",
  33.  *             "path"="/memberships/{membership_id}",
  34.  *             "identifiers"={"membership_id"},
  35.  *         }
  36.  *     },
  37.  *     collectionOperations={
  38.  *         "get"={
  39.  *             "method"="GET",
  40.  *             "path"="/memberships",
  41.  *             "identifiers"={"membership_id"},
  42.  *         },
  43.  *         "post"={
  44.  *             "method"="POST",
  45.  *             "path"="/memberships",
  46.  *             "identifiers"={"membership_id"},
  47.  *         }
  48.  *     }
  49.  * )
  50.  * @ApiPlatform\ApiFilter(AlphabeticalOrderFilter::class, properties={"name"="ASC"})
  51.  */
  52. class Membership extends \XLite\Model\Base\I18n
  53. {
  54.     /**
  55.      * Unique id
  56.      *
  57.      * @var integer
  58.      *
  59.      * @ORM\Id
  60.      * @ORM\GeneratedValue (strategy="AUTO")
  61.      * @ORM\Column         (type="integer", options={ "unsigned": true })
  62.      */
  63.     protected $membership_id;
  64.     /**
  65.      * Position
  66.      *
  67.      * @var integer
  68.      *
  69.      * @ORM\Column (type="integer")
  70.      */
  71.     protected $position 0;
  72.     /**
  73.      * Enabled status
  74.      *
  75.      * @var boolean
  76.      *
  77.      * @ORM\Column (type="boolean")
  78.      */
  79.     protected $enabled true;
  80.     /**
  81.      * Quick data
  82.      *
  83.      * @var \Doctrine\Common\Collections\Collection
  84.      *
  85.      * @ORM\OneToMany (targetEntity="XLite\Model\QuickData", mappedBy="membership", cascade={"all"}, fetch="LAZY")
  86.      */
  87.     protected $quickData;
  88.     /**
  89.      * Categories
  90.      *
  91.      * @var \Doctrine\Common\Collections\ArrayCollection
  92.      *
  93.      * @ORM\ManyToMany (targetEntity="XLite\Model\Category", mappedBy="memberships", fetch="LAZY")
  94.      */
  95.     protected $categories;
  96.     /**
  97.      * Products
  98.      *
  99.      * @var \Doctrine\Common\Collections\ArrayCollection
  100.      *
  101.      * @ORM\ManyToMany (targetEntity="XLite\Model\Product", mappedBy="memberships", fetch="LAZY")
  102.      */
  103.     protected $products;
  104.     /**
  105.      * @var \Doctrine\Common\Collections\Collection
  106.      *
  107.      * @ORM\OneToMany (targetEntity="XLite\Model\MembershipTranslation", mappedBy="owner", cascade={"all"})
  108.      */
  109.     protected $translations;
  110.     public function __construct(array $data = [])
  111.     {
  112.         parent::__construct($data);
  113.         $this->categories = new \Doctrine\Common\Collections\ArrayCollection();
  114.     }
  115.     /**
  116.      * Get membership_id
  117.      *
  118.      * @return integer
  119.      */
  120.     public function getMembershipId()
  121.     {
  122.         return $this->membership_id;
  123.     }
  124.     /**
  125.      * Set position
  126.      *
  127.      * @param integer $position
  128.      * @return Membership
  129.      */
  130.     public function setPosition($position)
  131.     {
  132.         $this->position $position;
  133.         return $this;
  134.     }
  135.     /**
  136.      * Get position
  137.      *
  138.      * @return integer
  139.      */
  140.     public function getPosition()
  141.     {
  142.         return $this->position;
  143.     }
  144.     /**
  145.      * Set enabled
  146.      *
  147.      * @param boolean $enabled
  148.      * @return Membership
  149.      */
  150.     public function setEnabled($enabled)
  151.     {
  152.         $this->enabled = (bool)$enabled;
  153.         return $this;
  154.     }
  155.     /**
  156.      * Get enabled
  157.      *
  158.      * @return boolean
  159.      */
  160.     public function getEnabled()
  161.     {
  162.         return $this->enabled;
  163.     }
  164.     /**
  165.      * Add quickData
  166.      *
  167.      * @param \XLite\Model\QuickData $quickData
  168.      * @return Membership
  169.      */
  170.     public function addQuickData(\XLite\Model\QuickData $quickData)
  171.     {
  172.         $this->quickData[] = $quickData;
  173.         return $this;
  174.     }
  175.     /**
  176.      * Get quickData
  177.      *
  178.      * @return \Doctrine\Common\Collections\Collection
  179.      */
  180.     public function getQuickData()
  181.     {
  182.         return $this->quickData;
  183.     }
  184.     /**
  185.      * Add categories
  186.      *
  187.      * @param \XLite\Model\Category $categories
  188.      * @return Membership
  189.      */
  190.     public function addCategories(\XLite\Model\Category $categories)
  191.     {
  192.         $this->categories[] = $categories;
  193.         return $this;
  194.     }
  195.     /**
  196.      * Get categories
  197.      *
  198.      * @return \Doctrine\Common\Collections\Collection
  199.      */
  200.     public function getCategories()
  201.     {
  202.         return $this->categories;
  203.     }
  204.     /**
  205.      * Add products
  206.      *
  207.      * @param \XLite\Model\Product $products
  208.      * @return Membership
  209.      */
  210.     public function addProducts(\XLite\Model\Product $products)
  211.     {
  212.         $this->products[] = $products;
  213.         return $this;
  214.     }
  215.     /**
  216.      * Get products
  217.      *
  218.      * @return \Doctrine\Common\Collections\Collection
  219.      */
  220.     public function getProducts()
  221.     {
  222.         return $this->products;
  223.     }
  224. }