src/AtechNet/CoreBundle/Entity/CustomerAddress.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\AtechNet\CoreBundle\Entity;
  3. use App\AtechNet\CoreBundle\Repository\CustomerAddressRepository;
  4. use Doctrine\ORM\Mapping\Column;
  5. use Doctrine\ORM\Mapping\Entity;
  6. use Doctrine\ORM\Mapping\JoinColumn;
  7. use Doctrine\ORM\Mapping\ManyToOne;
  8. use Doctrine\ORM\Mapping\Table as Table;
  9. /**
  10.  * CustomerAddress
  11.  *
  12.  * @Table(name="customers__address")
  13.  * @Entity(repositoryClass=CustomerAddressRepository::class)
  14.  */
  15. class CustomerAddress extends AbstractEntity
  16. {
  17.     /**
  18.      * @var string
  19.      *
  20.      * @Column(name="title", type="string", length=255, nullable=true)
  21.      */
  22.     private $title;
  23.     /**
  24.      * @var int
  25.      *
  26.      * @Column(name="type", type="integer", nullable=true)
  27.      */
  28.     private $type;
  29.     /**
  30.      * @var Customer
  31.      *
  32.      * @ManyToOne(targetEntity="Customer", inversedBy="addresses")
  33.      * @JoinColumn(name="customer_id", referencedColumnName="id")
  34.      */
  35.     private $customer;
  36.     /**
  37.      * @var string
  38.      *
  39.      * @Column(name="first_name", type="string", length=255, nullable=true)
  40.      */
  41.     private $firstName;
  42.     /**
  43.      * @var string
  44.      *
  45.      * @Column(name="last_name", type="string", length=255, nullable=true)
  46.      */
  47.     private $lastName;
  48.     /**
  49.      * @var string
  50.      *
  51.      * @Column(name="business_name", type="string", length=255, nullable=true)
  52.      */
  53.     private $businessName;
  54.     /**
  55.      * @var string
  56.      *
  57.      * @Column(name="street", type="string", length=255)
  58.      */
  59.     private $street;
  60.     /**
  61.      * @var string
  62.      *
  63.      * @Column(name="city", type="string", length=255)
  64.      */
  65.     private $city;
  66.     /**
  67.      * @var string
  68.      *
  69.      * @Column(name="zip", type="string", length=255)
  70.      */
  71.     private $zip;
  72.     /**
  73.      * @var string
  74.      *
  75.      * @Column(name="district", type="string", length=255)
  76.      */
  77.     private $district = '';
  78.     /**
  79.      * @var string
  80.      *
  81.      * @Column(name="country", type="string", length=255)
  82.      */
  83.     private $country;
  84.     /**
  85.      * @var string
  86.      *
  87.      * @Column(name="phone_number", type="string", length=255, nullable=true)
  88.      */
  89.     private $phone;
  90.     /**
  91.      * @var string
  92.      *
  93.      * @Column(name="email", type="string", length=255, nullable=true)
  94.      */
  95.     private $email;
  96.     /**
  97.      * @var string
  98.      *
  99.      * @Column(name="gps", type="string", length=255, nullable=true)
  100.      */
  101.     private $gps;
  102.     public const AddressType_Billing = 'billing';
  103.     public const AddressType_Shipping = 'shipping';
  104.     public const AddressType_Billing_Id = 0;
  105.     public const AddressType_Shipping_Id = 1;
  106.     public const EU_COUNTRIES = [
  107.         'AT' => 'Austria',
  108.         'BE' => 'Belgium',
  109.         'BG' => 'Bulgaria',
  110.         'HR' => 'Croatia',
  111.         'CY' => 'Cyprus',
  112.         'DK' => 'Denmark',
  113.         'EE' => 'Estonia',
  114.         'FI' => 'Finland',
  115.         'FR' => 'France',
  116.         'DE' => 'Germany',
  117.         'GR' => 'Greece',
  118.         'IE' => 'Ireland',
  119.         'IT' => 'Italy',
  120.         'LV' => 'Latvia',
  121.         'LT' => 'Lithuania',
  122.         'LU' => 'Luxemburg',
  123.         'MT' => 'Malta',
  124.         'NL' => 'Nederlands',
  125.         'PL' => 'Poland',
  126.         'PT' => 'Portugal',
  127.         'RO' => 'Romania',
  128.         'SI' => 'Slovenia',
  129.         'ES' => 'Spain',
  130.         'SE' => 'Sweden',
  131.         'HU' => 'Hungary',
  132.     ];
  133.     /**
  134.      * Returns the address types in array
  135.      *
  136.      * @return array
  137.      */
  138.     public static function getAddressTypes()
  139.     {
  140.         return [
  141.             self::AddressType_Billing,
  142.             self::AddressType_Shipping,
  143.         ];
  144.     }
  145.     public static function getCountries()
  146.     {
  147.         return [
  148.             'SK' => 'Slovenská republika',
  149.             'HU' => 'Magyarország',
  150.             'CZ' => 'Česká republika',
  151.         ];
  152.     }
  153.     /**
  154.      * @return int
  155.      */
  156.     public function getType()
  157.     {
  158.         return $this->type;
  159.     }
  160.     /**
  161.      * @param int $type
  162.      */
  163.     public function setType($type)
  164.     {
  165.         $this->type = $type;
  166.     }
  167.     /**
  168.      * @return Customer
  169.      */
  170.     public function getCustomer()
  171.     {
  172.         return $this->customer;
  173.     }
  174.     /**
  175.      * @param Customer $customer
  176.      */
  177.     public function setCustomer($customer)
  178.     {
  179.         $this->customer = $customer;
  180.     }
  181.     /**
  182.      * Set title
  183.      *
  184.      * @param string $title
  185.      * @return $this
  186.      */
  187.     public function setTitle($title)
  188.     {
  189.         $this->title = $title;
  190.         return $this;
  191.     }
  192.     /**
  193.      * Get title
  194.      *
  195.      * @return string
  196.      */
  197.     public function getTitle()
  198.     {
  199.         return $this->title;
  200.     }
  201.     /**
  202.      * Set firstName
  203.      *
  204.      * @param string $firstName
  205.      * @return string
  206.      */
  207.     public function setFirstName($firstName)
  208.     {
  209.         $this->firstName = ucfirst($firstName);
  210.         return $this;
  211.     }
  212.     /**
  213.      * Get firstName
  214.      *
  215.      * @return string
  216.      */
  217.     public function getFirstName()
  218.     {
  219.         return $this->firstName;
  220.     }
  221.     /**
  222.      * Set lastName
  223.      *
  224.      * @param string $lastName
  225.      * @return string
  226.      */
  227.     public function setLastName($lastName)
  228.     {
  229.         $this->lastName = ucfirst($lastName);
  230.         return $this;
  231.     }
  232.     /**
  233.      * Get lastName
  234.      *
  235.      * @return string
  236.      */
  237.     public function getLastName()
  238.     {
  239.         return $this->lastName;
  240.     }
  241.     /**
  242.      * Set businessTitle
  243.      *
  244.      * @param string $businessName
  245.      * @return string
  246.      */
  247.     public function setBusinessName($businessName)
  248.     {
  249.         $this->businessName = $businessName;
  250.         return $this;
  251.     }
  252.     /**
  253.      * Get businessTitle
  254.      *
  255.      * @return string
  256.      */
  257.     public function getBusinessName()
  258.     {
  259.         return $this->businessName;
  260.     }
  261.     /**
  262.      * Set street
  263.      *
  264.      * @param string $street
  265.      * @return CustomerAddress
  266.      */
  267.     public function setStreet($street)
  268.     {
  269.         $this->street = $street;
  270.         return $this;
  271.     }
  272.     /**
  273.      * Get street
  274.      *
  275.      * @return string
  276.      */
  277.     public function getStreet()
  278.     {
  279.         return $this->street;
  280.     }
  281.     /**
  282.      * Set city
  283.      *
  284.      * @param string $city
  285.      * @return CustomerAddress
  286.      */
  287.     public function setCity($city)
  288.     {
  289.         $this->city = $city;
  290.         return $this;
  291.     }
  292.     /**
  293.      * Get city
  294.      *
  295.      * @return string
  296.      */
  297.     public function getCity()
  298.     {
  299.         return $this->city;
  300.     }
  301.     /**
  302.      * Set zip
  303.      *
  304.      * @param string $zip
  305.      * @return CustomerAddress
  306.      */
  307.     public function setZip($zip)
  308.     {
  309.         $this->zip = $zip;
  310.         return $this;
  311.     }
  312.     /**
  313.      * Get zip
  314.      *
  315.      * @return string
  316.      */
  317.     public function getZip()
  318.     {
  319.         return $this->zip;
  320.     }
  321.     /**
  322.      * Set district
  323.      *
  324.      * @param string $district
  325.      * @return CustomerAddress
  326.      */
  327.     public function setDistrict($district)
  328.     {
  329.         $this->district = $district;
  330.         return $this;
  331.     }
  332.     /**
  333.      * Get district
  334.      *
  335.      * @return string
  336.      */
  337.     public function getDistrict()
  338.     {
  339.         return $this->district;
  340.     }
  341.     /**
  342.      * Set country
  343.      *
  344.      * @param string $country
  345.      * @return CustomerAddress
  346.      */
  347.     public function setCountry($country)
  348.     {
  349.         $this->country = $country;
  350.         return $this;
  351.     }
  352.     /**
  353.      * Get country
  354.      *
  355.      * @return string
  356.      */
  357.     public function getCountry()
  358.     {
  359.         return $this->country;
  360.     }
  361.     /**
  362.      * Set phoneNumber
  363.      *
  364.      * @param string $phone
  365.      * @return string
  366.      */
  367.     public function setPhone($phone)
  368.     {
  369.         $this->phone = $phone;
  370.         return $this;
  371.     }
  372.     /**
  373.      * Get phone
  374.      *
  375.      * @return string
  376.      */
  377.     public function getPhone()
  378.     {
  379.         return $this->phone;
  380.     }
  381.     /**
  382.      * @return string
  383.      */
  384.     public function getEmail()
  385.     {
  386.         return $this->email;
  387.     }
  388.     /**
  389.      * @param string $email
  390.      */
  391.     public function setEmail($email)
  392.     {
  393.         $this->email = $email;
  394.         return $this;
  395.     }
  396.     /**
  397.      * Set gps
  398.      *
  399.      * @param string $gps
  400.      * @return CustomerAddress
  401.      */
  402.     public function setGps($gps)
  403.     {
  404.         $this->gps = $gps;
  405.         return $this;
  406.     }
  407.     /**
  408.      * Get gps
  409.      *
  410.      * @return string
  411.      */
  412.     public function getGps()
  413.     {
  414.         return $this->gps;
  415.     }
  416.     public function checkRequiredFields()
  417.     {
  418.         if ($this->getCustomer() != null
  419.         && $this->getFirstName() != null && $this->getFirstName() != ''
  420.         && $this->getLastName() != null && $this->getLastName() != ''
  421.         && $this->getStreet() != null && $this->getStreet() != ''
  422.         && $this->getCity() != null && $this->getCity() != ''
  423.         && $this->getZip() != null && $this->getZip() != '') {
  424.             return true;
  425.         } else {
  426.             return false;
  427.         }
  428.     }
  429.     /**
  430.      * Return full name of $this address
  431.      *
  432.      * @return string
  433.      */
  434.     public function getFullName()
  435.     {
  436.         $fullName = '';
  437.         if ($this->getFirstName() != null && $this->getFirstName() != '') {
  438.             $fullName = $this->getFirstName();
  439.         }
  440.         if ($this->getLastName() != null && $this->getLastName() != '') {
  441.             $fullName .= ' ' . $this->getLastName();
  442.         }
  443.         return $fullName;
  444.     }
  445. }