src/Entity/Properties/Property.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Properties;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Symfony\Component\Validator\Constraints AS Assert;
  5. use Doctrine\ORM\Mapping AS ORM;
  6. use Ramsey\Uuid\Uuid;
  7. use Ramsey\Uuid\Lazy\LazyUuidFromString;
  8. use App\Entity\BaseEntity;
  9. use App\Entity\Landlords\Landlord;
  10. use App\Entity\Properties\Type;
  11. use App\Entity\Properties\Area;
  12. use App\Entity\Properties\Image;
  13. use App\Entity\Properties\PropertyFeature;
  14. use App\Entity\Maintenance\Maintenance;
  15. use App\Entity\Statements\Item;
  16. /**
  17.  * @ORM\Entity(repositoryClass="App\Repository\Properties\PropertyRepository")
  18.  * @ORM\Table(name="properties_property")
  19.  * @ORM\EntityListeners({"App\Listener\Entity\Properties\PropertyListener"})
  20.  */
  21. class Property extends BaseEntity
  22. {
  23.     /**
  24.     * @ORM\Id
  25.     * @ORM\GeneratedValue(strategy="AUTO")
  26.     * @ORM\Column(type="integer")
  27.     */
  28.     private $id;
  29.     /**
  30.      * @ORM\Column(type="uuid")
  31.      * @Assert\Uuid
  32.      */
  33.     protected $uuid;
  34.     /**
  35.      * @var \DateTime
  36.      *
  37.      * @ORM\Column(type="datetime", nullable=false)
  38.      * @Assert\Type("\DateTime")
  39.      */
  40.     private $created;
  41.     /**
  42.      * @var \DateTime
  43.      *
  44.      * @ORM\Column(type="datetime", nullable=false)
  45.      * @Assert\Type("\DateTime")
  46.      */
  47.     private $modified;
  48.     /**
  49.      * @ORM\Column(type="string", length=20, nullable=false)
  50.      * @Assert\NotBlank()
  51.      */
  52.     private $listingType;
  53.     /**
  54.     * @ORM\Column(type="integer", nullable=false)
  55.     */
  56.     private $reference;
  57.     /**
  58.      * @var \DateTime
  59.      *
  60.      * @ORM\Column(type="date", nullable=true)
  61.      * @Assert\Type("\DateTime")
  62.      */
  63.     private $dateAvailable;
  64.     /**
  65.      * @ORM\Column(type="string", length=128, nullable=false)
  66.      * @Assert\NotBlank()
  67.      */
  68.     private $nameNumber;
  69.     /**
  70.      * @ORM\Column(type="string", length=128, nullable=true)
  71.      */
  72.     private $address2;
  73.     /**
  74.      * @ORM\Column(type="string", length=128, nullable=true)
  75.      */
  76.     private $address3;
  77.     /**
  78.      * @ORM\Column(type="string", length=128, nullable=true)
  79.      */
  80.     private $address4;
  81.     /**
  82.      * @ORM\Column(type="string", length=128, nullable=false)
  83.      * @Assert\NotBlank()
  84.      */
  85.     private $town;
  86.     /**
  87.      * @ORM\Column(type="string", length=10, nullable=false)
  88.      * @Assert\NotBlank()
  89.      */
  90.     private $postcode;
  91.     /**
  92.      * @ORM\Column(type="decimal", precision=20, scale=16, nullable=true)
  93.      */
  94.     private $latitude;
  95.     /**
  96.      * @ORM\Column(type="decimal", precision=20, scale=16, nullable=true)
  97.      */
  98.     private $longitude;
  99.     /**
  100.      * @ORM\Column(type="integer", length=10, nullable=true)
  101.      */
  102.     private $rentalPrice;
  103.     /**
  104.      * @ORM\Column(type="integer", length=10, nullable=true)
  105.      */
  106.     private $monthlyRentalPrice;
  107.     /**
  108.      * @ORM\Column(type="string", length=10, nullable=true)
  109.      */
  110.     private $rentFrequency;
  111.     /**
  112.      * @ORM\Column(type="integer", length=10, nullable=true)
  113.      */
  114.     private $salePrice;
  115.     /**
  116.      * @ORM\Column(type="string", length=100, nullable=true)
  117.      */
  118.     private $cornerBanner;
  119.     /**
  120.      * @ORM\Column(type="text", nullable=false)
  121.      * @Assert\NotBlank()
  122.      */
  123.     private $summary;
  124.     /**
  125.      * @ORM\Column(type="text", nullable=false)
  126.      * @Assert\NotBlank()
  127.      */
  128.     private $description;
  129.     /**
  130.      * @ORM\Column(type="integer", length=4, nullable=false)
  131.      * @Assert\NotBlank()
  132.      */
  133.     private $bedrooms;
  134.     /**
  135.      * @ORM\Column(type="integer", length=4, nullable=false)
  136.      * @Assert\NotBlank()
  137.      */
  138.     private $bathrooms;
  139.     /**
  140.      * @ORM\Column(type="integer", length=4, nullable=false)
  141.      * @Assert\NotBlank()
  142.      */
  143.     private $receptionRooms;
  144.     /**
  145.      * @ORM\Column(type="string", length=255, nullable=true)
  146.      */
  147.     private $epcUrl;
  148.     /**
  149.      * @ORM\Column(type="boolean", nullable=false)
  150.      */
  151.     private $showOnWebsite;
  152.     /**
  153.      * @ORM\Column(type="boolean", nullable=false)
  154.      */
  155.     private $showOnRightMove;
  156.     /**
  157.      * @ORM\Column(type="integer", nullable=true, length=1)
  158.      */
  159.     private $rightMoveStatus;
  160.     /**
  161.      * @ORM\Column(type="datetime", nullable=true)
  162.      */
  163.     private $rightMoveLastUpdated;
  164.     /**
  165.      * @ORM\Column(type="string", length=255, nullable=true)
  166.      */
  167.     private $rightMoveListingURL;
  168.     /**
  169.      * @ORM\Column(type="boolean", nullable=false)
  170.      */
  171.     private $showOnZoopla;
  172.     /**
  173.      * @ORM\Column(type="integer", nullable=true, length=1)
  174.      */
  175.     private $zooplaStatus;
  176.     /**
  177.      * @ORM\Column(type="datetime", nullable=true)
  178.      */
  179.     private $zooplaLastUpdated;
  180.     /**
  181.      * @ORM\Column(type="string", length=255, nullable=true)
  182.      */
  183.     private $zooplaListingURL;
  184.     /**
  185.      * @ORM\Column(type="boolean", nullable=false)
  186.      */
  187.     private $showOnHousr;
  188.     /**
  189.      * @ORM\Column(type="integer", nullable=true, length=1)
  190.      */
  191.     private $housrStatus;
  192.     /**
  193.      * @ORM\Column(type="datetime", nullable=true)
  194.      */
  195.     private $housrLastUpdated;
  196.     /**
  197.      * @ORM\Column(type="integer", nullable=true)
  198.      */
  199.     private $housrPropertyId;
  200.     /**
  201.      * @ORM\Column(type="integer", length=10, nullable=false)
  202.      */
  203.     private $billableMonthlyRent;
  204.     /**
  205.      * @ORM\ManyToOne(targetEntity=Landlord::class, inversedBy="properties")
  206.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  207.      **/
  208.     private $landlord;
  209.     /**
  210.      * @ORM\ManyToOne(targetEntity=Type::class, inversedBy="properties")
  211.      * @ORM\JoinColumn(nullable=false)
  212.      **/
  213.     private $type;
  214.     /**
  215.      * @ORM\ManyToOne(targetEntity=Area::class, inversedBy="properties")
  216.      * @ORM\JoinColumn(nullable=false)
  217.      **/
  218.     private $area;
  219.     /**
  220.      * @ORM\OneToMany(targetEntity=Image::class, mappedBy="property", cascade={"persist", "remove"})
  221.      **/
  222.     private $images;
  223.     /**
  224.      * @ORM\ManyToOne(targetEntity=Image::class)
  225.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  226.      **/
  227.     private $featuredImage;
  228.     /**
  229.      * @ORM\OneToMany(targetEntity=Maintenance::class, mappedBy="property", cascade={"persist", "remove"})
  230.      **/
  231.     private $maintenance;
  232.     /**
  233.      * @ORM\OneToMany(targetEntity=Item::class, mappedBy="property", cascade={"persist", "remove"})
  234.      **/
  235.     private $statementItems;
  236.     /**
  237.      * @ORM\OneToMany(targetEntity=PropertyFeature::class, mappedBy="property", cascade={"persist", "remove"})
  238.      **/
  239.     private $propertyFeatures;
  240.     public function __construct(array $defaults = array())
  241.     {
  242.         // Defaults
  243.         $this->setUuid(Uuid::uuid4());
  244.         $this->setCreated(new \DateTime());
  245.         $this->setModified(new \DateTime());
  246.         $this->images = new ArrayCollection();
  247.         $this->propertyFeatures = new ArrayCollection();
  248.         $this->bedrooms 0;
  249.         $this->bathrooms 0;
  250.         $this->receptionRooms 0;
  251.         $this->showOnWebsite true;
  252.         $this->showOnRightMove true;
  253.         $this->rightMoveStatus null;
  254.         $this->rightMoveLastUpdated null;
  255.         $this->showOnZoopla true;
  256.         $this->zooplaStatus null;
  257.         $this->zooplaLastUpdated null;
  258.         $this->showOnHousr false;
  259.         $this->housrStatus null;
  260.         $this->housrLastUpdated null;
  261.         $this->housrPropertyId null;
  262.         $this->billableMonthlyRent 0;
  263.         parent::__construct($defaults);
  264.     }
  265.     public function getMicroAddress(): array
  266.     {
  267.         return array_filter([
  268.             $this->getNameNumber(),
  269.             $this->getAddress2()
  270.         ]);
  271.     }
  272.     public function getShortAddress(): array
  273.     {
  274.         return array_filter([
  275.             $this->getNameNumber(),
  276.             $this->getAddress2(),
  277.             $this->getPostcode()
  278.         ]);
  279.     }
  280.     public function getFullAddress(): array
  281.     {
  282.         return array_filter([
  283.             $this->getNameNumber(),
  284.             $this->getAddress2(),
  285.             $this->getAddress3(),
  286.             $this->getAddress4(),
  287.             $this->getTown(),
  288.             $this->getPostcode()
  289.         ]);
  290.     }
  291.     public function __toString()
  292.     {
  293.         return $this->getId();
  294.     }
  295.     public function getId(): ?int
  296.     {
  297.         return $this->id;
  298.     }
  299.     public function getUuid(): LazyUuidFromString
  300.     {
  301.         return $this->uuid;
  302.     }
  303.     public function setUuid(LazyUuidFromString $uuid): void
  304.     {
  305.         $this->uuid $uuid;
  306.     }
  307.     public function setCreated(\DateTime $created): void
  308.     {
  309.         $this->created $created;
  310.     }
  311.     public function getCreated(): \DateTime
  312.     {
  313.         return $this->created;
  314.     }
  315.     public function getModified() : \DateTime
  316.     {
  317.         return $this->modified;
  318.     }
  319.     public function setModified(\DateTime $modified): void
  320.     {
  321.         $this->modified $modified;
  322.     }
  323.     public function getDateAvailable(): ?\DateTime
  324.     {
  325.         return $this->dateAvailable;
  326.     }
  327.     public function setDateAvailable(\DateTime $dateAvailable null): void
  328.     {
  329.         $this->dateAvailable $dateAvailable;
  330.     }
  331.     public function getNameNumber(): string
  332.     {
  333.         return $this->nameNumber;
  334.     }
  335.     public function setNameNumber(string $nameNumber): void
  336.     {
  337.         $this->nameNumber $nameNumber;
  338.     }
  339.     public function getAddress2(): ?string
  340.     {
  341.         return $this->address2;
  342.     }
  343.     public function setAddress2(string $address2 null): void
  344.     {
  345.         $this->address2 $address2;
  346.     }
  347.     public function getAddress3(): ?string
  348.     {
  349.         return $this->address3;
  350.     }
  351.     public function setAddress3(string $address3 null): void
  352.     {
  353.         $this->address3 $address3;
  354.     }
  355.     public function getAddress4(): ?string
  356.     {
  357.         return $this->address4;
  358.     }
  359.     public function setAddress4(string $address4 null): void
  360.     {
  361.         $this->address4 $address4;
  362.     }
  363.     public function getTown(): string
  364.     {
  365.         return $this->town;
  366.     }
  367.     public function setTown(string $town): void
  368.     {
  369.         $this->town $town;
  370.     }
  371.     public function getPostcode(): string
  372.     {
  373.         return $this->postcode;
  374.     }
  375.     public function setPostcode(string $postcode): void
  376.     {
  377.         // Sanitize it
  378.         $postcode strtoupper(preg_replace("/[^A-Za-z0-9 ]/"''$postcode));
  379.         $this->postcode $postcode;
  380.     }
  381.     public function getType(): ?Type
  382.     {
  383.         return $this->type;
  384.     }
  385.     public function setType(Type $type): void
  386.     {
  387.         $this->type $type;
  388.     }
  389.     public function getArea(): ?Area
  390.     {
  391.         return $this->area;
  392.     }
  393.     public function setArea(Area $area): void
  394.     {
  395.         $this->area $area;
  396.     }
  397.     public function getRentalPrice(): int
  398.     {
  399.         return $this->rentalPrice;
  400.     }
  401.     public function setRentalPrice(int $rentalPrice null): void
  402.     {
  403.         $this->rentalPrice $rentalPrice;
  404.     }
  405.     public function getSummary(): string
  406.     {
  407.         return $this->summary;
  408.     }
  409.     public function setSummary(string $summary): void
  410.     {
  411.         $this->summary $summary;
  412.     }
  413.     public function getDescription(): string
  414.     {
  415.         return $this->description;
  416.     }
  417.     public function setDescription(string $description): void
  418.     {
  419.         $this->description $description;
  420.     }
  421.     public function getBedrooms(): int
  422.     {
  423.         return $this->bedrooms;
  424.     }
  425.     public function setBedrooms(int $bedrooms): void
  426.     {
  427.         $this->bedrooms $bedrooms;
  428.     }
  429.     public function getBathrooms(): int
  430.     {
  431.         return $this->bathrooms;
  432.     }
  433.     public function setBathrooms(int $bathrooms): void
  434.     {
  435.         $this->bathrooms $bathrooms;
  436.     }
  437.     public function getReceptionRooms(): int
  438.     {
  439.         return $this->receptionRooms;
  440.     }
  441.     public function setReceptionRooms(int $receptionRooms): void
  442.     {
  443.         $this->receptionRooms $receptionRooms;
  444.     }
  445.     public function getRentFrequency()
  446.     {
  447.         return $this->rentFrequency;
  448.     }
  449.     public function setRentFrequency(string $rentFrequency null): void
  450.     {
  451.         $this->rentFrequency $rentFrequency;
  452.     }
  453.     public function getPropertyFeatures()
  454.     {
  455.         return $this->propertyFeatures;
  456.     }
  457.     public function getReference()
  458.     {
  459.         return $this->reference;
  460.     }
  461.     public function setReference(int $reference)
  462.     {
  463.         $this->reference $reference;
  464.     }
  465.     public function getLatitude()
  466.     {
  467.         return $this->latitude;
  468.     }
  469.     public function setLatitude(float $latitude null)
  470.     {
  471.         $this->latitude $latitude;
  472.     }
  473.     public function getLongitude()
  474.     {
  475.         return $this->longitude;
  476.     }
  477.     public function setLongitude(float $longitude null)
  478.     {
  479.         $this->longitude $longitude;
  480.     }
  481.     public function getListingType()
  482.     {
  483.         return $this->listingType;
  484.     }
  485.     public function setListingType(string $listingType)
  486.     {
  487.         if(!in_array($listingType, ["letting""sale"]))
  488.             throw new \Exception("Invalid listing type: " $listingType);
  489.         $this->listingType $listingType;
  490.     }
  491.     public function getSalePrice()
  492.     {
  493.         return $this->salePrice;
  494.     }
  495.     public function setSalePrice(int $salePrice null)
  496.     {
  497.         $this->salePrice $salePrice;
  498.     }
  499.     public function getMonthlyRentalPrice()
  500.     {
  501.         return $this->monthlyRentalPrice;
  502.     }
  503.     public function setMonthlyRentalPrice(float $monthlyRentalPrice null)
  504.     {
  505.         $this->monthlyRentalPrice $monthlyRentalPrice;
  506.     }
  507.     public function getFeaturedImage()
  508.     {
  509.         return $this->featuredImage;
  510.     }
  511.     public function setFeaturedImage(Image $featuredImage null)
  512.     {
  513.         $this->featuredImage $featuredImage;
  514.     }
  515.     public function getEpcUrl()
  516.     {
  517.         return $this->epcUrl;
  518.     }
  519.     public function setEpcUrl(string $epcUrl null)
  520.     {
  521.         $this->epcUrl $epcUrl;
  522.     }
  523.     public function getShowOnWebsite()
  524.     {
  525.         return $this->showOnWebsite;
  526.     }
  527.     public function setShowOnWebsite(bool $showOnWebsite)
  528.     {
  529.         $this->showOnWebsite $showOnWebsite;
  530.     }
  531.     public function getShowOnRightMove()
  532.     {
  533.         return $this->showOnRightMove;
  534.     }
  535.     public function setShowOnRightMove(bool $showOnRightMove)
  536.     {
  537.         $this->showOnRightMove $showOnRightMove;
  538.     }
  539.     public function getShowOnZoopla()
  540.     {
  541.         return $this->showOnZoopla;
  542.     }
  543.     public function setShowOnZoopla(bool $showOnZoopla)
  544.     {
  545.         $this->showOnZoopla $showOnZoopla;
  546.     }
  547.     public function getRightMoveStatus()
  548.     {
  549.         return $this->rightMoveStatus;
  550.     }
  551.     public function setRightMoveStatus(int $rightMoveStatus null)
  552.     {
  553.         $this->rightMoveStatus $rightMoveStatus;
  554.     }
  555.     public function getRightMoveLastUpdated()
  556.     {
  557.         return $this->rightMoveLastUpdated;
  558.     }
  559.     public function setRightMoveLastUpdated(\DateTime $rightMoveLastUpdated null)
  560.     {
  561.         $this->rightMoveLastUpdated $rightMoveLastUpdated;
  562.     }
  563.     public function getZooplaStatus()
  564.     {
  565.         return $this->zooplaStatus;
  566.     }
  567.     public function setZooplaStatus(int $zooplaStatus null)
  568.     {
  569.         $this->zooplaStatus $zooplaStatus;
  570.     }
  571.     public function getZooplaLastUpdated()
  572.     {
  573.         return $this->zooplaLastUpdated;
  574.     }
  575.     public function setZooplaLastUpdated(\DateTime $zooplaLastUpdated null)
  576.     {
  577.         $this->zooplaLastUpdated $zooplaLastUpdated;
  578.     }
  579.     public function getImages()
  580.     {
  581.         return $this->images;
  582.     }
  583.     public function getCornerBanner()
  584.     {
  585.         return $this->cornerBanner;
  586.     }
  587.     public function setCornerBanner(string $cornerBanner null)
  588.     {
  589.         $this->cornerBanner $cornerBanner;
  590.     }
  591.     public function getRightMoveListingURL()
  592.     {
  593.         return $this->rightMoveListingURL;
  594.     }
  595.     public function setRightMoveListingURL(string $rightMoveListingURL null)
  596.     {
  597.         $this->rightMoveListingURL $rightMoveListingURL;
  598.     }
  599.     public function getZooplaListingURL()
  600.     {
  601.         return $this->zooplaListingURL;
  602.     }
  603.     public function setZooplaListingURL(string $zooplaListingURL null)
  604.     {
  605.         $this->zooplaListingURL $zooplaListingURL;
  606.     }
  607.     public function getShowOnHousr()
  608.     {
  609.         return $this->showOnHousr;
  610.     }
  611.     public function setShowOnHousr(bool $showOnHousr)
  612.     {
  613.         $this->showOnHousr $showOnHousr;
  614.     }
  615.     public function getHousrStatus()
  616.     {
  617.         return $this->housrStatus;
  618.     }
  619.     public function setHousrStatus(int $housrStatus null)
  620.     {
  621.         $this->housrStatus $housrStatus;
  622.     }
  623.     public function getHousrLastUpdated()
  624.     {
  625.         return $this->housrLastUpdated;
  626.     }
  627.     public function setHousrLastUpdated(\DateTime $housrLastUpdated null)
  628.     {
  629.         $this->housrLastUpdated $housrLastUpdated;
  630.     }
  631.     public function getHousrPropertyId()
  632.     {
  633.         return $this->housrPropertyId;
  634.     }
  635.     public function setHousrPropertyId(int $housrPropertyId null)
  636.     {
  637.         $this->housrPropertyId $housrPropertyId;
  638.     }
  639.     public function getLandlord()
  640.     {
  641.         return $this->landlord;
  642.     }
  643.     public function setLandlord(Landlord $landlord null)
  644.     {
  645.         $this->landlord $landlord;
  646.     }
  647.     public function getBillableMonthlyRent()
  648.     {
  649.         return $this->billableMonthlyRent;
  650.     }
  651.     public function setBillableMonthlyRent(int $billableMonthlyRent)
  652.     {
  653.         $this->billableMonthlyRent $billableMonthlyRent;
  654.     }
  655. }