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="string", length=255, nullable=true)
  150.      */
  151.     private $virtualTourUrl;
  152.     /**
  153.      * @ORM\Column(type="integer", nullable=true)
  154.      */
  155.     private $furnishedType;
  156.     /**
  157.      * @ORM\Column(type="integer", nullable=true)
  158.      */
  159.     private $deposit;
  160.     /**
  161.      * @ORM\Column(type="boolean", nullable=true)
  162.      */
  163.     private $petsAllowed;
  164.     /**
  165.      * @ORM\Column(type="text", nullable=true)
  166.      */
  167.     private $parking;
  168.     /**
  169.      * @ORM\Column(type="boolean", nullable=true)
  170.      */
  171.     private $allBillsIncluded;
  172.     /**
  173.      * @ORM\Column(type="integer", nullable=true)
  174.      */
  175.     private $minimumTerm;
  176.     /**
  177.      * @ORM\Column(type="boolean", nullable=false)
  178.      */
  179.     private $showOnWebsite;
  180.     /**
  181.      * @ORM\Column(type="boolean", nullable=false)
  182.      */
  183.     private $showOnRightMove;
  184.     /**
  185.      * @ORM\Column(type="integer", nullable=true, length=1)
  186.      */
  187.     private $rightMoveStatus;
  188.     /**
  189.      * @ORM\Column(type="datetime", nullable=true)
  190.      */
  191.     private $rightMoveLastUpdated;
  192.     /**
  193.      * @ORM\Column(type="string", length=255, nullable=true)
  194.      */
  195.     private $rightMoveListingURL;
  196.     /**
  197.      * @ORM\Column(type="boolean", nullable=false)
  198.      */
  199.     private $showOnZoopla;
  200.     /**
  201.      * @ORM\Column(type="integer", nullable=true, length=1)
  202.      */
  203.     private $zooplaStatus;
  204.     /**
  205.      * @ORM\Column(type="datetime", nullable=true)
  206.      */
  207.     private $zooplaLastUpdated;
  208.     /**
  209.      * @ORM\Column(type="string", length=255, nullable=true)
  210.      */
  211.     private $zooplaListingURL;
  212.     /**
  213.      * @ORM\Column(type="integer", length=10, nullable=false)
  214.      */
  215.     private $billableMonthlyRent;
  216.     /**
  217.      * @ORM\ManyToOne(targetEntity=Landlord::class, inversedBy="properties")
  218.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  219.      **/
  220.     private $landlord;
  221.     /**
  222.      * @ORM\ManyToOne(targetEntity=Type::class, inversedBy="properties")
  223.      * @ORM\JoinColumn(nullable=false)
  224.      **/
  225.     private $type;
  226.     /**
  227.      * @ORM\ManyToOne(targetEntity=Area::class, inversedBy="properties")
  228.      * @ORM\JoinColumn(nullable=false)
  229.      **/
  230.     private $area;
  231.     /**
  232.      * @ORM\OneToMany(targetEntity=Image::class, mappedBy="property", cascade={"persist", "remove"})
  233.      **/
  234.     private $images;
  235.     /**
  236.      * @ORM\ManyToOne(targetEntity=Image::class)
  237.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  238.      **/
  239.     private $featuredImage;
  240.     /**
  241.      * @ORM\OneToMany(targetEntity=Maintenance::class, mappedBy="property", cascade={"persist", "remove"})
  242.      **/
  243.     private $maintenance;
  244.     /**
  245.      * @ORM\OneToMany(targetEntity=Item::class, mappedBy="property", cascade={"persist", "remove"})
  246.      **/
  247.     private $statementItems;
  248.     /**
  249.      * @ORM\OneToMany(targetEntity=PropertyFeature::class, mappedBy="property", cascade={"persist", "remove"})
  250.      **/
  251.     private $propertyFeatures;
  252.     public function __construct(array $defaults = array())
  253.     {
  254.         // Defaults
  255.         $this->setUuid(Uuid::uuid4());
  256.         $this->setCreated(new \DateTime());
  257.         $this->setModified(new \DateTime());
  258.         $this->images = new ArrayCollection();
  259.         $this->propertyFeatures = new ArrayCollection();
  260.         $this->bedrooms 0;
  261.         $this->bathrooms 0;
  262.         $this->receptionRooms 0;
  263.         $this->showOnWebsite true;
  264.         $this->showOnRightMove true;
  265.         $this->rightMoveStatus null;
  266.         $this->rightMoveLastUpdated null;
  267.         $this->showOnZoopla true;
  268.         $this->zooplaStatus null;
  269.         $this->zooplaLastUpdated null;
  270.         $this->billableMonthlyRent 0;
  271.         parent::__construct($defaults);
  272.     }
  273.     public function getMicroAddress(): array
  274.     {
  275.         return array_filter([
  276.             $this->getNameNumber(),
  277.             $this->getAddress2()
  278.         ]);
  279.     }
  280.     public function getShortAddress(): array
  281.     {
  282.         return array_filter([
  283.             $this->getNameNumber(),
  284.             $this->getAddress2(),
  285.             $this->getPostcode()
  286.         ]);
  287.     }
  288.     public function getFullAddress(): array
  289.     {
  290.         return array_filter([
  291.             $this->getNameNumber(),
  292.             $this->getAddress2(),
  293.             $this->getAddress3(),
  294.             $this->getAddress4(),
  295.             $this->getTown(),
  296.             $this->getPostcode()
  297.         ]);
  298.     }
  299.     public function __toString()
  300.     {
  301.         return $this->getId();
  302.     }
  303.     public function getId(): ?int
  304.     {
  305.         return $this->id;
  306.     }
  307.     public function getUuid(): LazyUuidFromString
  308.     {
  309.         return $this->uuid;
  310.     }
  311.     public function setUuid(LazyUuidFromString $uuid): void
  312.     {
  313.         $this->uuid $uuid;
  314.     }
  315.     public function setCreated(\DateTime $created): void
  316.     {
  317.         $this->created $created;
  318.     }
  319.     public function getCreated(): \DateTime
  320.     {
  321.         return $this->created;
  322.     }
  323.     public function getModified() : \DateTime
  324.     {
  325.         return $this->modified;
  326.     }
  327.     public function setModified(\DateTime $modified): void
  328.     {
  329.         $this->modified $modified;
  330.     }
  331.     public function getDateAvailable(): ?\DateTime
  332.     {
  333.         return $this->dateAvailable;
  334.     }
  335.     public function setDateAvailable(\DateTime $dateAvailable null): void
  336.     {
  337.         $this->dateAvailable $dateAvailable;
  338.     }
  339.     public function getNameNumber(): string
  340.     {
  341.         return $this->nameNumber;
  342.     }
  343.     public function setNameNumber(string $nameNumber): void
  344.     {
  345.         $this->nameNumber $nameNumber;
  346.     }
  347.     public function getAddress2(): ?string
  348.     {
  349.         return $this->address2;
  350.     }
  351.     public function setAddress2(string $address2 null): void
  352.     {
  353.         $this->address2 $address2;
  354.     }
  355.     public function getAddress3(): ?string
  356.     {
  357.         return $this->address3;
  358.     }
  359.     public function setAddress3(string $address3 null): void
  360.     {
  361.         $this->address3 $address3;
  362.     }
  363.     public function getAddress4(): ?string
  364.     {
  365.         return $this->address4;
  366.     }
  367.     public function setAddress4(string $address4 null): void
  368.     {
  369.         $this->address4 $address4;
  370.     }
  371.     public function getTown(): string
  372.     {
  373.         return $this->town;
  374.     }
  375.     public function setTown(string $town): void
  376.     {
  377.         $this->town $town;
  378.     }
  379.     public function getPostcode(): string
  380.     {
  381.         return $this->postcode;
  382.     }
  383.     public function setPostcode(string $postcode): void
  384.     {
  385.         // Sanitize it
  386.         $postcode strtoupper(preg_replace("/[^A-Za-z0-9 ]/"''$postcode));
  387.         $this->postcode $postcode;
  388.     }
  389.     public function getType(): ?Type
  390.     {
  391.         return $this->type;
  392.     }
  393.     public function setType(Type $type): void
  394.     {
  395.         $this->type $type;
  396.     }
  397.     public function getArea(): ?Area
  398.     {
  399.         return $this->area;
  400.     }
  401.     public function setArea(Area $area): void
  402.     {
  403.         $this->area $area;
  404.     }
  405.     public function getRentalPrice(): int
  406.     {
  407.         return $this->rentalPrice;
  408.     }
  409.     public function setRentalPrice(int $rentalPrice null): void
  410.     {
  411.         $this->rentalPrice $rentalPrice;
  412.     }
  413.     public function getSummary(): string
  414.     {
  415.         return $this->summary;
  416.     }
  417.     public function setSummary(string $summary): void
  418.     {
  419.         $this->summary $summary;
  420.     }
  421.     public function getDescription(): string
  422.     {
  423.         return $this->description;
  424.     }
  425.     public function setDescription(string $description): void
  426.     {
  427.         $this->description $description;
  428.     }
  429.     public function getBedrooms(): int
  430.     {
  431.         return $this->bedrooms;
  432.     }
  433.     public function setBedrooms(int $bedrooms): void
  434.     {
  435.         $this->bedrooms $bedrooms;
  436.     }
  437.     public function getBathrooms(): int
  438.     {
  439.         return $this->bathrooms;
  440.     }
  441.     public function setBathrooms(int $bathrooms): void
  442.     {
  443.         $this->bathrooms $bathrooms;
  444.     }
  445.     public function getReceptionRooms(): int
  446.     {
  447.         return $this->receptionRooms;
  448.     }
  449.     public function setReceptionRooms(int $receptionRooms): void
  450.     {
  451.         $this->receptionRooms $receptionRooms;
  452.     }
  453.     public function getRentFrequency()
  454.     {
  455.         return $this->rentFrequency;
  456.     }
  457.     public function setRentFrequency(string $rentFrequency null): void
  458.     {
  459.         $this->rentFrequency $rentFrequency;
  460.     }
  461.     public function getPropertyFeatures()
  462.     {
  463.         return $this->propertyFeatures;
  464.     }
  465.     public function getReference()
  466.     {
  467.         return $this->reference;
  468.     }
  469.     public function setReference(int $reference)
  470.     {
  471.         $this->reference $reference;
  472.     }
  473.     public function getLatitude()
  474.     {
  475.         return $this->latitude;
  476.     }
  477.     public function setLatitude(float $latitude null)
  478.     {
  479.         $this->latitude $latitude;
  480.     }
  481.     public function getLongitude()
  482.     {
  483.         return $this->longitude;
  484.     }
  485.     public function setLongitude(float $longitude null)
  486.     {
  487.         $this->longitude $longitude;
  488.     }
  489.     public function getListingType()
  490.     {
  491.         return $this->listingType;
  492.     }
  493.     public function setListingType(string $listingType)
  494.     {
  495.         if(!in_array($listingType, ["letting""sale"]))
  496.             throw new \Exception("Invalid listing type: " $listingType);
  497.         $this->listingType $listingType;
  498.     }
  499.     public function getSalePrice()
  500.     {
  501.         return $this->salePrice;
  502.     }
  503.     public function setSalePrice(int $salePrice null)
  504.     {
  505.         $this->salePrice $salePrice;
  506.     }
  507.     public function getMonthlyRentalPrice()
  508.     {
  509.         return $this->monthlyRentalPrice;
  510.     }
  511.     public function setMonthlyRentalPrice(float $monthlyRentalPrice null)
  512.     {
  513.         $this->monthlyRentalPrice $monthlyRentalPrice;
  514.     }
  515.     public function getFeaturedImage()
  516.     {
  517.         return $this->featuredImage;
  518.     }
  519.     public function setFeaturedImage(Image $featuredImage null)
  520.     {
  521.         $this->featuredImage $featuredImage;
  522.     }
  523.     public function getEpcUrl()
  524.     {
  525.         return $this->epcUrl;
  526.     }
  527.     public function setEpcUrl(string $epcUrl null)
  528.     {
  529.         $this->epcUrl $epcUrl;
  530.     }
  531.     public function getVirtualTourUrl()
  532.     {
  533.         return $this->virtualTourUrl;
  534.     }
  535.     public function setVirtualTourUrl(string $virtualTourUrl null)
  536.     {
  537.         $this->virtualTourUrl $virtualTourUrl;
  538.     }
  539.     public function getFurnishedType()
  540.     {
  541.         return $this->furnishedType;
  542.     }
  543.     public function setFurnishedType(int $furnishedType null)
  544.     {
  545.         $this->furnishedType $furnishedType;
  546.     }
  547.     public function getDeposit()
  548.     {
  549.         return $this->deposit;
  550.     }
  551.     public function setDeposit(int $deposit null)
  552.     {
  553.         $this->deposit $deposit;
  554.     }
  555.     public function getPetsAllowed()
  556.     {
  557.         return $this->petsAllowed;
  558.     }
  559.     public function setPetsAllowed(bool $petsAllowed null)
  560.     {
  561.         $this->petsAllowed $petsAllowed;
  562.     }
  563.     public function getParking()
  564.     {
  565.         return $this->parking;
  566.     }
  567.     public function setParking(string $parking null)
  568.     {
  569.         $this->parking $parking;
  570.     }
  571.     public function getAllBillsIncluded()
  572.     {
  573.         return $this->allBillsIncluded;
  574.     }
  575.     public function setAllBillsIncluded(bool $allBillsIncluded null)
  576.     {
  577.         $this->allBillsIncluded $allBillsIncluded;
  578.     }
  579.     public function getMinimumTerm()
  580.     {
  581.         return $this->minimumTerm;
  582.     }
  583.     public function setMinimumTerm(int $minimumTerm null)
  584.     {
  585.         $this->minimumTerm $minimumTerm;
  586.     }
  587.     public function getShowOnWebsite()
  588.     {
  589.         return $this->showOnWebsite;
  590.     }
  591.     public function setShowOnWebsite(bool $showOnWebsite)
  592.     {
  593.         $this->showOnWebsite $showOnWebsite;
  594.     }
  595.     public function getShowOnRightMove()
  596.     {
  597.         return $this->showOnRightMove;
  598.     }
  599.     public function setShowOnRightMove(bool $showOnRightMove)
  600.     {
  601.         $this->showOnRightMove $showOnRightMove;
  602.     }
  603.     public function getShowOnZoopla()
  604.     {
  605.         return $this->showOnZoopla;
  606.     }
  607.     public function setShowOnZoopla(bool $showOnZoopla)
  608.     {
  609.         $this->showOnZoopla $showOnZoopla;
  610.     }
  611.     public function getRightMoveStatus()
  612.     {
  613.         return $this->rightMoveStatus;
  614.     }
  615.     public function setRightMoveStatus(int $rightMoveStatus null)
  616.     {
  617.         $this->rightMoveStatus $rightMoveStatus;
  618.     }
  619.     public function getRightMoveLastUpdated()
  620.     {
  621.         return $this->rightMoveLastUpdated;
  622.     }
  623.     public function setRightMoveLastUpdated(\DateTime $rightMoveLastUpdated null)
  624.     {
  625.         $this->rightMoveLastUpdated $rightMoveLastUpdated;
  626.     }
  627.     public function getZooplaStatus()
  628.     {
  629.         return $this->zooplaStatus;
  630.     }
  631.     public function setZooplaStatus(int $zooplaStatus null)
  632.     {
  633.         $this->zooplaStatus $zooplaStatus;
  634.     }
  635.     public function getZooplaLastUpdated()
  636.     {
  637.         return $this->zooplaLastUpdated;
  638.     }
  639.     public function setZooplaLastUpdated(\DateTime $zooplaLastUpdated null)
  640.     {
  641.         $this->zooplaLastUpdated $zooplaLastUpdated;
  642.     }
  643.     public function getImages()
  644.     {
  645.         return $this->images;
  646.     }
  647.     public function getCornerBanner()
  648.     {
  649.         return $this->cornerBanner;
  650.     }
  651.     public function setCornerBanner(string $cornerBanner null)
  652.     {
  653.         $this->cornerBanner $cornerBanner;
  654.     }
  655.     public function getRightMoveListingURL()
  656.     {
  657.         return $this->rightMoveListingURL;
  658.     }
  659.     public function setRightMoveListingURL(string $rightMoveListingURL null)
  660.     {
  661.         $this->rightMoveListingURL $rightMoveListingURL;
  662.     }
  663.     public function getZooplaListingURL()
  664.     {
  665.         return $this->zooplaListingURL;
  666.     }
  667.     public function setZooplaListingURL(string $zooplaListingURL null)
  668.     {
  669.         $this->zooplaListingURL $zooplaListingURL;
  670.     }
  671.     public function getLandlord()
  672.     {
  673.         return $this->landlord;
  674.     }
  675.     public function setLandlord(Landlord $landlord null)
  676.     {
  677.         $this->landlord $landlord;
  678.     }
  679.     public function getBillableMonthlyRent()
  680.     {
  681.         return $this->billableMonthlyRent;
  682.     }
  683.     public function setBillableMonthlyRent(int $billableMonthlyRent)
  684.     {
  685.         $this->billableMonthlyRent $billableMonthlyRent;
  686.     }
  687. }