classes/XLite/Model/Region.php line 25

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 Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * Region is a model for grouping states
  10.  *
  11.  * @ORM\Entity
  12.  * @ORM\Table (name="regions",
  13.  *      uniqueConstraints={
  14.  *          @ORM\UniqueConstraint (name="code", columns={"code","country_code"})
  15.  *      },
  16.  *      indexes={
  17.  *          @ORM\Index (name="name", columns={"name"})
  18.  *      }
  19.  * )
  20.  */
  21. class Region extends \XLite\Model\AEntity
  22. {
  23.     /**
  24.      * Region code
  25.      *
  26.      * @var string
  27.      *
  28.      * @ORM\Id
  29.      * @ORM\Column (type="string", length=10)
  30.      */
  31.     protected $code;
  32.     /**
  33.      * Region name
  34.      *
  35.      * @var string
  36.      *
  37.      * @ORM\Column (type="string", length=64)
  38.      */
  39.     protected $name;
  40.     /**
  41.      * Region weight
  42.      *
  43.      * @var integer
  44.      *
  45.      * @ORM\Column (type="integer", nullable=true)
  46.      */
  47.     protected $weight;
  48.     /**
  49.      * Country (relation)
  50.      *
  51.      * @var \XLite\Model\Country
  52.      *
  53.      * @ORM\ManyToOne (targetEntity="XLite\Model\Country", inversedBy="regions", cascade={"merge","detach"})
  54.      * @ORM\JoinColumn (name="country_code", referencedColumnName="code", onDelete="CASCADE")
  55.      */
  56.     protected $country;
  57.     /**
  58.      * States (relation)
  59.      *
  60.      * @var \Doctrine\Common\Collections\ArrayCollection
  61.      *
  62.      * @ORM\OneToMany (targetEntity="XLite\Model\State", mappedBy="region", cascade={"all"})
  63.      * @ORM\OrderBy   ({"state" = "ASC"})
  64.      */
  65.     protected $states;
  66.     /**
  67.      * Set code
  68.      *
  69.      * @param string $code
  70.      * @return Region
  71.      */
  72.     public function setCode($code)
  73.     {
  74.         $this->code $code;
  75.         return $this;
  76.     }
  77.     /**
  78.      * Get code
  79.      *
  80.      * @return string
  81.      */
  82.     public function getCode()
  83.     {
  84.         return $this->code;
  85.     }
  86.     /**
  87.      * Set name
  88.      *
  89.      * @param string $name
  90.      * @return Region
  91.      */
  92.     public function setName($name)
  93.     {
  94.         $this->name $name;
  95.         return $this;
  96.     }
  97.     /**
  98.      * Get name
  99.      *
  100.      * @return string
  101.      */
  102.     public function getName()
  103.     {
  104.         return $this->name;
  105.     }
  106.     /**
  107.      * Set weight
  108.      *
  109.      * @param integer $weight
  110.      * @return Region
  111.      */
  112.     public function setWeight($weight)
  113.     {
  114.         $this->weight $weight;
  115.         return $this;
  116.     }
  117.     /**
  118.      * Get weight
  119.      *
  120.      * @return integer
  121.      */
  122.     public function getWeight()
  123.     {
  124.         return $this->weight;
  125.     }
  126.     /**
  127.      * Set country
  128.      *
  129.      * @param \XLite\Model\Country $country
  130.      * @return Region
  131.      */
  132.     public function setCountry(\XLite\Model\Country $country null)
  133.     {
  134.         $this->country $country;
  135.         return $this;
  136.     }
  137.     /**
  138.      * Get country
  139.      *
  140.      * @return \XLite\Model\Country
  141.      */
  142.     public function getCountry()
  143.     {
  144.         return $this->country;
  145.     }
  146.     /**
  147.      * Add states
  148.      *
  149.      * @param \XLite\Model\State $states
  150.      * @return Region
  151.      */
  152.     public function addStates(\XLite\Model\State $states)
  153.     {
  154.         $this->states[] = $states;
  155.         return $this;
  156.     }
  157.     /**
  158.      * Get states
  159.      *
  160.      * @return \Doctrine\Common\Collections\Collection
  161.      */
  162.     public function getStates()
  163.     {
  164.         return $this->states;
  165.     }
  166. }