src/Aqarmap/Bundle/ListingBundle/Entity/Listing.php line 82

Open in your IDE?
  1. <?php
  2. namespace Aqarmap\Bundle\ListingBundle\Entity;
  3. use Aqarmap\Bundle\FinancialAidsBundle\Entity\FinancialAid;
  4. use Aqarmap\Bundle\FinancialAidsBundle\Utilities\FinancialAidURL;
  5. use Aqarmap\Bundle\ListingBundle\Constant\CompoundStatus;
  6. use Aqarmap\Bundle\ListingBundle\Constant\EligibleForMortgageData;
  7. use Aqarmap\Bundle\ListingBundle\Constant\ListingCategories;
  8. use Aqarmap\Bundle\ListingBundle\Constant\ListingCustomFields;
  9. use Aqarmap\Bundle\ListingBundle\Constant\ListingFeaturedTypes;
  10. use Aqarmap\Bundle\ListingBundle\Constant\ListingFeatures;
  11. use Aqarmap\Bundle\ListingBundle\Constant\ListingPaymentMethod;
  12. use Aqarmap\Bundle\ListingBundle\Constant\ListingPriceLevel;
  13. use Aqarmap\Bundle\ListingBundle\Constant\ListingPropertyView;
  14. use Aqarmap\Bundle\ListingBundle\Constant\ListingRateConstant;
  15. use Aqarmap\Bundle\ListingBundle\Constant\ListingRateReviewStatus;
  16. use Aqarmap\Bundle\ListingBundle\Constant\ListingRateStatus;
  17. use Aqarmap\Bundle\ListingBundle\Constant\ListingSections;
  18. use Aqarmap\Bundle\ListingBundle\Constant\ListingSellerRoles;
  19. use Aqarmap\Bundle\ListingBundle\Constant\ListingStatus;
  20. use Aqarmap\Bundle\ListingBundle\Constant\PhotoTypes;
  21. use Aqarmap\Bundle\ListingBundle\Constant\PluralCustomFields;
  22. use Aqarmap\Bundle\ListingBundle\Constant\PropertyRegistrationStatusOption;
  23. use Aqarmap\Bundle\ListingBundle\Document\ScrapedListing;
  24. use Aqarmap\Bundle\ListingBundle\Entity\Traits\CallLog;
  25. use Aqarmap\Bundle\ListingBundle\Security\Authorization\OwnerInterface;
  26. use Aqarmap\Bundle\ListingBundle\Validator\Constraints as AqarMapAssert;
  27. use Aqarmap\Bundle\UserBundle\Constant\TeamCategories;
  28. use Aqarmap\Bundle\UserBundle\Entity\User;
  29. use Aqarmap\Bundle\UserBundle\Model\UserMainPhones;
  30. use Doctrine\Common\Collections\ArrayCollection;
  31. use Doctrine\Common\Collections\Collection;
  32. use Doctrine\Common\Collections\Criteria;
  33. use Doctrine\ORM\Mapping as ORM;
  34. use Gedmo\Mapping\Annotation as Gedmo;
  35. use Gedmo\Translatable\Translatable;
  36. use JMS\Serializer\Annotation as Serializer;
  37. use Symfony\Component\Validator\Constraints as Assert;
  38. /**
  39.  * Listing.
  40.  *
  41.  * @ORM\Table(name="listings", indexes={
  42.  *
  43.  *     @ORM\Index(columns={"pending_photos_status"}),
  44.  *     @ORM\Index(columns={"pending_payment_status"}),
  45.  *     @ORM\Index(columns={"relist_status"}),
  46.  *     @ORM\Index(columns={"featured"}),
  47.  *     @ORM\Index(columns={"deleted_at"}),
  48.  *     @ORM\Index(columns={"created_at"}),
  49.  *     @ORM\Index(columns={"published_at"}),
  50.  *     @ORM\Index(columns={"user_id", "deleted_at"}),
  51.  *     @ORM\Index(columns={"user_id", "status"}),
  52.  *     @ORM\Index(columns={"user_id", "status", "deleted_at"}),
  53.  *     @ORM\Index(columns={"user_id", "status", "location_id"}),
  54.  *     @ORM\Index(columns={"user_id", "status", "location_id", "parent_id", "category", "deleted_at"}),
  55.  *     @ORM\Index(columns={"user_id", "status", "location_id", "property_type_id", "section_id", "parent_id", "category", "deleted_at"}),
  56.  *     @ORM\Index(columns={"location_id", "section_id", "property_type_id", "status", "published_at"}),
  57.  *     @ORM\Index(columns={"user_id", "section_id", "leads_counter"}),
  58.  *     @ORM\Index(columns={"category", "parent_id", "updated_at"}),
  59.  *     @ORM\Index(columns={"category", "parent_id", "waiting_time"}),
  60.  *     @ORM\Index(columns={"status", "category", "parent_id"}),
  61.  *     @ORM\Index(columns={"reference_number"}),
  62.  *     @ORM\Index(columns={"status", "leads_counter"}),
  63.  *     @ORM\Index(columns={"user_id", "creation_source", "deleted_at"}),
  64.  *     @ORM\Index(columns={"status", "location_id", "parent_id", "user_id", "deleted_at"}),
  65.  *     @ORM\Index(columns={"is_availability_email_sent"}),
  66.  *
  67.  * })
  68.  *
  69.  * @ORM\HasLifecycleCallbacks
  70.  *
  71.  * @ORM\Entity(repositoryClass="Aqarmap\Bundle\ListingBundle\Repository\ListingRepository")
  72.  *
  73.  * @Gedmo\TranslationEntity(class="Aqarmap\Bundle\ListingBundle\Entity\ListingTranslation")
  74.  *
  75.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  76.  *
  77.  * @Serializer\ExclusionPolicy("all")
  78.  */
  79. class Listing implements OwnerInterfaceTranslatable
  80. {
  81.     use CallLog;
  82.     /**
  83.      * @var int
  84.      *
  85.      * @ORM\Column(name="id", type="integer")
  86.      *
  87.      * @ORM\Id
  88.      *
  89.      * @ORM\GeneratedValue(strategy="AUTO")
  90.      *
  91.      * @Serializer\Groups({
  92.      *     "Default", "List", "listingDetails", "listingDetailsWithLocationCompound", "Details", "Activity",
  93.      *     "DataLayer", "ActivitiesData", "DefaultV4", "MyListing", "MyListings", "SearchV4", "ProjectSearchV4",
  94.      *     "ProjectDetailsV4", "UnitDetails", "Autocomplete", "RelatedListingsV2", "SlugResolver", "locationListingV2",
  95.      *     "homeCompoundV2", "MyLeads", "NewLeadGeneration"
  96.      * })
  97.      *
  98.      * @Serializer\Expose
  99.      */
  100.     private $id;
  101.     /**
  102.      * @ORM\OneToMany(targetEntity="Listing", mappedBy="parent")
  103.      *
  104.      * @ORM\OrderBy({"area" = "ASC"})
  105.      *
  106.      * @Serializer\Groups({"List", "Details"})
  107.      *
  108.      * @Serializer\Expose
  109.      *
  110.      * @Serializer\Until("v2.1")
  111.      */
  112.     private $children;
  113.     /**
  114.      * @ORM\ManyToOne(targetEntity="Listing", inversedBy="children")
  115.      *
  116.      * @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
  117.      *
  118.      * @Serializer\Groups({"List", "Details", "DataLayer", "UnitDetails"})
  119.      *
  120.      * @Serializer\Expose
  121.      *
  122.      * @Serializer\Until("v2.1")
  123.      *
  124.      * @Serializer\MaxDepth(1)
  125.      */
  126.     private $parent;
  127.     /**
  128.      * @ORM\OneToOne(targetEntity="Listing")
  129.      *
  130.      * @ORM\JoinColumn(name="relist_id", referencedColumnName="id")
  131.      */
  132.     private $relistParent;
  133.     /**
  134.      * @ORM\Column(name="title", type="string", length=128, nullable=true)
  135.      *
  136.      * @Gedmo\Translatable
  137.      *
  138.      * @Serializer\Groups({
  139.      *     "Default", "List", "Details", "listingDetails", "listingDetailsWithLocationCompound", "Activity", "Preview",
  140.      *     "DefaultV4", "MyListing", "MyListings", "SearchV4", "ProjectSearchV4", "ProjectDetailsV4", "Autocomplete",
  141.      *     "RelatedListingsV2", "SlugResolver","locationListingV2", "homeCompoundV2", "MyLeads"
  142.      * })
  143.      *
  144.      * @Serializer\Expose
  145.      *
  146.      * @Assert\NotBlank(message="listing.title_required", groups={"step2"})
  147.      */
  148.     private ?string $title null;
  149.     /**
  150.      * @ORM\Column(name="description", type="text", length=1024, nullable=true)
  151.      *
  152.      * @Gedmo\Translatable
  153.      *
  154.      * @Serializer\Groups({"List", "Details", "listingDetails", "Activity", "DefaultV4", "MyListing", "MyListings", "SearchV4", "ProjectDetailsV4"})
  155.      *
  156.      * @Serializer\Expose
  157.      *
  158.      * @Assert\NotBlank(message="listing.description_required", groups={"step2"})
  159.      */
  160.     private ?string $description null;
  161.     /**
  162.      * @ORM\ManyToOne(targetEntity="Section", inversedBy="listings")
  163.      *
  164.      * @ORM\JoinColumn(name="section_id", referencedColumnName="id")
  165.      *
  166.      * @Serializer\Groups({"MyListings", "List", "Details", "listingDetails", "DataLayer", "DefaultV4", "MyListing", "SearchV4"})
  167.      *
  168.      * @Serializer\Expose
  169.      *
  170.      * @Assert\NotBlank(groups={"API"})
  171.      */
  172.     protected $section;
  173.     /**
  174.      * @var int
  175.      *
  176.      * @ORM\Column(name="category", type="smallint", nullable=false)
  177.      *
  178.      * @Serializer\Groups({"List", "Details", "listingDetails"})
  179.      *
  180.      * @Serializer\Expose
  181.      */
  182.     private $category;
  183.     /**
  184.      * @var int
  185.      *
  186.      * @ORM\Column(name="pending_photos_status", type="smallint", nullable=true)
  187.      */
  188.     private $pendingPhotosStatus;
  189.     /**
  190.      * @var int
  191.      *
  192.      * @ORM\Column(name="pending_payment_status", type="smallint", nullable=true)
  193.      */
  194.     private $pendingPaymentStatus;
  195.     /**
  196.      * @var int
  197.      *
  198.      * @ORM\Column(name="relist_status", type="smallint", nullable=true)
  199.      */
  200.     private $relistStatus;
  201.     /**
  202.      * @ORM\Column(name="seller_role", type="smallint", nullable=true)
  203.      *
  204.      * @Serializer\Expose
  205.      *
  206.      * @Serializer\Groups({"Details", "listingDetails"})
  207.      *
  208.      * @Serializer\Since("v2.1")
  209.      */
  210.     private ?int $sellerRole null;
  211.     private $sellerRoleLabel;
  212.     /**
  213.      * @var int
  214.      *
  215.      * @ORM\Column(name="area", type="integer", nullable=true)
  216.      *
  217.      * @Serializer\Groups({"List", "Details", "DefaultV4", "MyListing", "MyListings", "SearchV4", "UnitDetails", "RelatedListingsV2", "listingDetails"})
  218.      *
  219.      * @Serializer\Expose
  220.      *
  221.      * @Assert\NotBlank(message="listing.area_required", groups={"step2"})
  222.      *
  223.      * @Assert\GreaterThan(value = 1, message="listing.area_minimum", groups={"step2"})
  224.      */
  225.     private $area;
  226.     /**
  227.      * CAUTION: type-hint string to avoid unnecessary update on every fetch.
  228.      *
  229.      * @ORM\Column(name="price", type="bigint", nullable=true)
  230.      *
  231.      * @Serializer\Groups({"List", "Details", "listingDetails", "Activity", "Preview", "DefaultV4", "MyListing", "MyListings", "SearchV4", "UnitDetails", "RelatedListingsV2"})
  232.      *
  233.      * @Serializer\Expose
  234.      *
  235.      * @Assert\NotBlank(message="listing.price_required", groups={"step2"})
  236.      *
  237.      * @Assert\GreaterThan(value = 100, message="listing.price_minimum", groups={"step2"})
  238.      */
  239.     private ?string $price null;
  240.     /**
  241.      * @var string
  242.      *
  243.      * @ORM\Column(name="address", type="text", length=512, nullable=true)
  244.      *
  245.      * @Gedmo\Translatable
  246.      *
  247.      * @Serializer\Groups({"List", "Details", "listingDetails", "Activity", "Preview", "DefaultV4", "SearchV4", "RelatedListingsV2", "locationListingV2", "homeCompoundV2", "MyListings"})
  248.      *
  249.      * @Serializer\Expose
  250.      *
  251.      * @Assert\Length(max=100)
  252.      *
  253.      * @Assert\NotBlank(message="listing.address_required", groups={"step2"})
  254.      */
  255.     private $address;
  256.     /**
  257.      * @var float
  258.      *
  259.      * @ORM\Column(name="center_lat", type="float", nullable=true)
  260.      *
  261.      * @Serializer\Groups({"List", "Details", "listingDetails"})
  262.      *
  263.      * @Serializer\Expose
  264.      */
  265.     private $centerLat;
  266.     /**
  267.      * @var float
  268.      *
  269.      * @ORM\Column(name="center_lng", type="float", nullable=true)
  270.      *
  271.      * @Serializer\Groups({"List", "Details", "listingDetails"})
  272.      *
  273.      * @Serializer\Expose
  274.      */
  275.     private $centerLng;
  276.     /**
  277.      * @var int
  278.      *
  279.      * @ORM\Column(name="status", type="smallint", nullable=true)
  280.      *
  281.      * @Serializer\Groups({"List", "Details", "Activity", "listingDetails"})
  282.      *
  283.      * @Serializer\Expose
  284.      */
  285.     private $status;
  286.     private $statusLabel;
  287.     /**
  288.      * @var int
  289.      *
  290.      * @Serializer\Groups({"List", "Details", "listingDetails", "SearchV4"})
  291.      *
  292.      * @Serializer\Expose
  293.      *
  294.      * @ORM\Column(name="property_view", type="smallint", nullable=true)
  295.      */
  296.     private $propertyView;
  297.     private $propertyViewLabel;
  298.     /**
  299.      * @var int
  300.      *
  301.      * @Serializer\Groups({"List", "Details"})
  302.      *
  303.      * @Serializer\Expose
  304.      *
  305.      * @ORM\Column(name="payment_method", type="smallint", nullable=true)
  306.      */
  307.     private $paymentMethod;
  308.     private $paymentMethodLabel;
  309.     /**
  310.      * @var bool
  311.      *
  312.      * @ORM\Column(name="featured", type="smallint", nullable=true)
  313.      */
  314.     private $featured;
  315.     /**
  316.      * @var int
  317.      *
  318.      * @ORM\Column(name="views", type="integer", nullable=true)
  319.      *
  320.      * @Serializer\Groups({"Api", "MyListing"})
  321.      *
  322.      * @Serializer\Expose
  323.      */
  324.     private $views 0;
  325.     /**
  326.      * @var int
  327.      *
  328.      * @ORM\Column(name="phone_counter", type="integer", options={"default" = 0})
  329.      *
  330.      * @Serializer\Groups({"Api"})
  331.      *
  332.      * @Serializer\Expose
  333.      */
  334.     private $phoneCounter 0;
  335.     /**
  336.      * @var int
  337.      *
  338.      * @ORM\Column(name="messages_counter", type="integer", options={"default" = 0})
  339.      *
  340.      * @Serializer\Groups({"Api"})
  341.      *
  342.      * @Serializer\Expose
  343.      */
  344.     private $messagesCounter 0;
  345.     /**
  346.      * @ORM\Column(name="leads_counter", type="integer", options={"default" = 0})
  347.      *
  348.      * @Serializer\Groups({"Api"})
  349.      *
  350.      * @Serializer\Expose
  351.      */
  352.     private int $leadsCounter 0;
  353.     /**
  354.      * @var int
  355.      *
  356.      * @ORM\Column(name="sent_notifiers", type="integer", nullable=true)
  357.      */
  358.     private $sentNotifiers;
  359.     /**
  360.      * @var int
  361.      *
  362.      * @ORM\Column(name="relist_counter", type="integer", nullable=true)
  363.      */
  364.     private $relistCounter;
  365.     /**
  366.      * @var string
  367.      *
  368.      * @ORM\Column(name="ip", type="string", length=50, nullable=true)
  369.      */
  370.     private $ip;
  371.     /**
  372.      * @var string
  373.      *
  374.      * @ORM\Column(name="video_url", type="string", length=150, nullable=true)
  375.      *
  376.      * @AqarMapAssert\IsYoutubeUrlOrNull
  377.      *
  378.      * @Serializer\Groups({"List", "Details", "listingDetails", "Activity", "DefaultV4", "ProjectSearchV4", "ProjectDetailsV4"})
  379.      *
  380.      * @Serializer\Expose
  381.      */
  382.     private $videoUrl;
  383.     /**
  384.      * @ORM\Column(name="slug", length=128, nullable=true)
  385.      *
  386.      * @Serializer\Groups({"locationListingV2", "SearchV4", "listingDetails"})
  387.      *
  388.      * @Serializer\Expose
  389.      */
  390.     private $slug;
  391.     /**
  392.      * @ORM\Column(name="custom_slug", length=50, unique=true, nullable=true)
  393.      *
  394.      * @Serializer\Groups({"DataLayer"})
  395.      *
  396.      * @Serializer\Expose
  397.      */
  398.     private $customSlug;
  399.     /**
  400.      * @var int
  401.      *
  402.      * @ORM\Column(name="score", type="float", nullable=true)
  403.      */
  404.     private $score;
  405.     /**
  406.      * @ORM\Column(name="created_at", type="datetime", nullable=true)
  407.      *
  408.      * @Serializer\Groups({"MyListings"})
  409.      *
  410.      * @Serializer\Expose()
  411.      */
  412.     private $createdAt;
  413.     /**
  414.      * @var \DateTime
  415.      *
  416.      * @ORM\Column(name="updated_at", type="datetime", nullable=true)
  417.      *
  418.      * @Serializer\Groups({"Details", "DefaultV4", "List", "SearchV4", "listingDetails"})
  419.      *
  420.      * @Serializer\Expose()
  421.      */
  422.     private $updatedAt;
  423.     /**
  424.      * @var \DateTime
  425.      *
  426.      * @ORM\Column(name="pending_status_created_at", type="datetime", nullable=true)
  427.      *
  428.      * @Serializer\Groups({"Details", "DefaultV4", "List","SearchV4"})
  429.      *
  430.      * @Serializer\Expose()
  431.      */
  432.     private $pendingStatusCreatedAt;
  433.     /**
  434.      * @var \DateTime
  435.      *
  436.      * @ORM\Column(name="published_at", type="datetime", nullable=true)
  437.      *
  438.      * @Serializer\Groups({"List", "Details", "DefaultV4", "SearchV4", "ProjectSearchV4", "ProjectDetailsV4", "MyListings"})
  439.      *
  440.      * @Serializer\Expose
  441.      *
  442.      * @Assert\Range(
  443.      *      max = "now",
  444.      *      maxMessage = "listing.date_not_allowed"
  445.      * )
  446.      */
  447.     private $publishedAt;
  448.     /**
  449.      * @var \DateTime;
  450.      */
  451.     private $aggregatedPublishedAt;
  452.     /**
  453.      * @var \DateTime
  454.      *
  455.      * @ORM\Column(name="expires_at", type="datetime", nullable=true)
  456.      *
  457.      * @Serializer\Groups({"DefaultV4", "MyListing", "MyListings"})
  458.      *
  459.      * @Serializer\Expose
  460.      */
  461.     private $expiresAt;
  462.     /**
  463.      * @ORM\Column(name="deleted_at", type="datetime", nullable=true)
  464.      *
  465.      * @Serializer\Groups({"listingDetails"})
  466.      *
  467.      * @Serializer\Expose
  468.      */
  469.     private $deletedAt;
  470.     /**
  471.      * @ORM\Column(name="rejected_at", type="datetime", nullable=true)
  472.      */
  473.     private $rejectedAt;
  474.     /**
  475.      * @ORM\OrderBy({"averagePricePerMeter" = "DESC"})
  476.      *
  477.      * @ORM\OneToMany(targetEntity="CompoundAveragePrice", mappedBy="parentCompound", cascade={"all"})
  478.      **/
  479.     private $compoundAveragePrices;
  480.     /**
  481.      * @ORM\ManyToOne(targetEntity="PropertyType", inversedBy="listings")
  482.      *
  483.      * @ORM\JoinColumn(name="property_type_id", referencedColumnName="id")
  484.      *
  485.      * @Serializer\Groups({"MyListings", "List", "Details", "listingDetails", "Activity", "DefaultV4", "SearchV4", "MyLeads"})
  486.      *
  487.      * @Serializer\Expose
  488.      *
  489.      * @Assert\NotBlank(groups={"API"})
  490.      */
  491.     protected $propertyType;
  492.     /**
  493.      * @ORM\ManyToOne(targetEntity="Location", inversedBy="listings")
  494.      *
  495.      * @ORM\JoinColumn(name="location_id", referencedColumnName="id")
  496.      *
  497.      * @Serializer\Groups({"List", "Details", "listingDetails", "Activity", "DefaultV4", "SearchV4", "ProjectDetailsV4", "RelatedListingsV2"})
  498.      *
  499.      * @Serializer\Expose
  500.      */
  501.     protected $location;
  502.     /**
  503.      * @ORM\ManyToMany(targetEntity="Location")
  504.      *
  505.      * @ORM\JoinTable(
  506.      *      name="listings_locations",
  507.      *      joinColumns={@ORM\JoinColumn(name="listing_id", referencedColumnName="id")},
  508.      *      inverseJoinColumns={@ORM\JoinColumn(name="location_id", referencedColumnName="id")}
  509.      * )
  510.      **/
  511.     protected $locations;
  512.     /**
  513.      * @ORM\ManyToOne(targetEntity="CompoundLocation", inversedBy="listings")
  514.      *
  515.      * @ORM\JoinColumn(name="compound_location_id", referencedColumnName="id", nullable=true)
  516.      *
  517.      * @Serializer\Groups({"Default", "ProjectSearchV4"})
  518.      *
  519.      * @Serializer\Expose
  520.      **/
  521.     protected $compoundLocation;
  522.     /**
  523.      * @ORM\ManyToOne(targetEntity="\Aqarmap\Bundle\UserBundle\Entity\User", inversedBy="listings")
  524.      *
  525.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)
  526.      *
  527.      * @Serializer\Groups({"List", "Details", "listingDetails", "DefaultV4", "MyListing", "SearchV4", "ProjectDetailsV4", "ProjectSearchV4", "RelatedListingsV2", "MyListings", "MyLeads"})
  528.      *
  529.      * @Serializer\Expose
  530.      */
  531.     protected $user;
  532.     /**
  533.      * @ORM\ManyToMany(targetEntity="\Aqarmap\Bundle\UserBundle\Entity\User", fetch="EXTRA_LAZY")
  534.      *
  535.      * @ORM\JoinTable(
  536.      *      name="listings_participants",
  537.      *      joinColumns={@ORM\JoinColumn(name="listing_id", referencedColumnName="id")},
  538.      *      inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}
  539.      * )
  540.      **/
  541.     protected $participants;
  542.     /**
  543.      * @ORM\OneToMany(targetEntity="ListingAttribute", mappedBy="listing", cascade={"all"}, orphanRemoval=true)
  544.      *
  545.      * @Serializer\Groups({"List", "Details", "Preview", "listingDetails"})
  546.      *
  547.      * @Serializer\Expose
  548.      *
  549.      * @Assert\Valid
  550.      **/
  551.     protected $attributes;
  552.     /**
  553.      * @ORM\OneToMany(
  554.      *     targetEntity="ListingPhone",
  555.      *     mappedBy="listing",
  556.      *     cascade={"all"},
  557.      *     orphanRemoval=true
  558.      *     )
  559.      *
  560.      * @Assert\Valid
  561.      **/
  562.     protected $phones;
  563.     /**
  564.      * @ORM\OneToMany(targetEntity="ListingPhoto", mappedBy="listing", cascade={"persist", "remove"}, orphanRemoval=true)
  565.      **/
  566.     protected $photos;
  567.     /**
  568.      * @ORM\OneToMany(
  569.      *   targetEntity="ListingTranslation",
  570.      *   mappedBy="object",
  571.      *   cascade={"all"},
  572.      *   orphanRemoval=true
  573.      * )
  574.      */
  575.     private $translations;
  576.     /**
  577.      * @ORM\OneToMany(targetEntity="Aqarmap\Bundle\ListingBundle\Entity\ListingLead", mappedBy="listing", fetch="EXTRA_LAZY")
  578.      **/
  579.     protected $leads;
  580.     /**
  581.      * @ORM\OneToMany(targetEntity="ListingFeature", mappedBy="listing")
  582.      **/
  583.     protected $listingFeatures;
  584.     /**
  585.      * @ORM\OneToMany(targetEntity="ListingNotification", mappedBy="listing")
  586.      **/
  587.     protected $ListingNotifications;
  588.     /**
  589.      * @ORM\ManyToMany(targetEntity="Rejection")
  590.      *
  591.      * @ORM\JoinTable(name="listings_rejections",
  592.      *      joinColumns={@ORM\JoinColumn(name="listing_id", referencedColumnName="id")},
  593.      *      inverseJoinColumns={@ORM\JoinColumn(name="rejection_id", referencedColumnName="id")}
  594.      *      )
  595.      *
  596.      * @Serializer\Groups({"userListing"})
  597.      *
  598.      * @Serializer\Expose
  599.      *
  600.      **/
  601.     protected $rejections;
  602.     /**
  603.      * @var string
  604.      *
  605.      * @ORM\Column(name="campaign", type="string", length=50, nullable=true)
  606.      *
  607.      * @Serializer\Groups({"List", "Details", "DefaultV4", "MyListing"})
  608.      *
  609.      * @Serializer\Expose
  610.      */
  611.     private $campaign;
  612.     /**
  613.      * @var int
  614.      *
  615.      * @ORM\Column(name="final_price", type="integer", nullable=true)
  616.      */
  617.     private $finalPrice;
  618.     /**
  619.      * @var string
  620.      *
  621.      * @ORM\Column(name="source_of_sale", type="string", nullable=true)
  622.      */
  623.     private $sourceOfSale;
  624.     /**
  625.      * @var string
  626.      *
  627.      * @ORM\Column(name="delete_reason", type="string", length=100, nullable=true)
  628.      */
  629.     private $deleteReason;
  630.     /**
  631.      * @var string
  632.      *
  633.      * @ORM\Column(name="delete_reason_details", type="text", nullable=true)
  634.      */
  635.     private $deleteReasonDetails;
  636.     /**
  637.      * @ORM\OneToMany(targetEntity="Aqarmap\Bundle\ListingBundle\Entity\Interaction",mappedBy="listing")
  638.      */
  639.     private $interactions;
  640.     /**
  641.      * @var string
  642.      */
  643.     private $userLogo;
  644.     /**
  645.      * @var string
  646.      */
  647.     private $listingLogo;
  648.     /**
  649.      * @Gedmo\Locale()
  650.      */
  651.     private $locale;
  652.     /**
  653.      * @ORM\Column(name="source",type="string",nullable=true)
  654.      */
  655.     private $source;
  656.     private $elasticSearchScore;
  657.     /**
  658.      * @var float
  659.      */
  660.     private $qualityScore;
  661.     /**
  662.      * @ORM\Column(name="impressions", type="integer", options={"default" = 0})
  663.      *
  664.      * @Serializer\SerializedName("impressions_count")
  665.      *
  666.      * @Serializer\Groups({"List", "Details", "MyListing", "MyListings"})
  667.      *
  668.      * @Serializer\Expose
  669.      */
  670.     private int $impressions 0;
  671.     /**
  672.      * @ORM\Column(name="impressions_monthly_count", type="integer", options={"default" = 0})
  673.      *
  674.      * @Serializer\SerializedName("impressions_monthly_count")
  675.      *
  676.      * @Serializer\Groups({"List", "Details"})
  677.      *
  678.      * @Serializer\Expose
  679.      */
  680.     private int $impressionsMonthlyCount 0;
  681.     /**
  682.      * @ORM\Column(name="impressions_weekly_count", type="integer", options={"default" = 0})
  683.      *
  684.      * @Serializer\SerializedName("impressions_weekly_count")
  685.      *
  686.      * @Serializer\Groups({"List", "Details"})
  687.      *
  688.      * @Serializer\Expose
  689.      */
  690.     private int $impressionsWeeklyCount 0;
  691.     /**
  692.      * @var \DateTime
  693.      *
  694.      * @ORM\Column(name="impression_updated_at", type="datetime", nullable=true)
  695.      */
  696.     private $impressionUpdatedAt;
  697.     /**
  698.      * @ORM\Column(name="price_level", type="smallint", nullable=true)
  699.      *
  700.      * @Serializer\Expose
  701.      */
  702.     private $priceLevel;
  703.     /**
  704.      * @var string
  705.      */
  706.     private $priceLevelLabel;
  707.     /**
  708.      * @ORM\Column(name="compound_status", type="smallint", nullable=true)
  709.      *
  710.      * @Serializer\Expose
  711.      */
  712.     private $compoundStatus;
  713.     /**
  714.      * @var string
  715.      */
  716.     private $compoundStatusLabel;
  717.     /**
  718.      * @ORM\Column(name="price_per_meter", type="float", nullable=true)
  719.      *
  720.      * @Serializer\Expose
  721.      *
  722.      * @Serializer\Groups({"listingDetails"})
  723.      */
  724.     private $pricePerMeter;
  725.     /**
  726.      * @ORM\Column(name="is_bumped", type="boolean", nullable=true)
  727.      */
  728.     private ?bool $isBumped false;
  729.     /**
  730.      * @ORM\Column(name="is_send_email", type="boolean", options={"default" = 1})
  731.      *
  732.      * @Serializer\Expose()
  733.      *
  734.      * @Serializer\Groups({"DefaultV4", "SearchV4", "RelatedListingsV2"})
  735.      */
  736.     private $isSendEmail true;
  737.     /**
  738.      * @ORM\Column(name="is_availability_email_sent", type="boolean", options={"default" = 0})
  739.      */
  740.     private $isAvailabilityEmailSent false;
  741.     /**
  742.      * @ORM\Column(name="market_property_type", type="smallint", nullable=true)
  743.      *
  744.      * @Serializer\Groups({"DefaultV4","SearchV4","Details"})
  745.      *
  746.      * @Serializer\Expose
  747.      */
  748.     private ?int $marketPropertyType null;
  749.     /**
  750.      * @var int
  751.      *
  752.      * @ORM\Column(name="creation_source", type="smallint", nullable=true)
  753.      */
  754.     private $creationSource;
  755.     /**
  756.      * @deprecated
  757.      *
  758.      * @var int
  759.      *
  760.      * @ORM\Column(name="click_through_rate", type="float", options={"default" = 0})
  761.      */
  762.     private $clickThroughRate 0;
  763.     /**
  764.      * @var int
  765.      *
  766.      * @ORM\Column(name="label", type="smallint", nullable=true)
  767.      */
  768.     private $label;
  769.     /**
  770.      * @ORM\Column(name="is_top_picks", type="boolean", options={"default" = 0})
  771.      */
  772.     private $isTopPicks false;
  773.     /**
  774.      * @var int
  775.      *
  776.      * @ORM\Column(name="contact_rate", type="float", options={"default" = 0})
  777.      */
  778.     private $contactRate 0;
  779.     /**
  780.      * @ORM\OneToMany(targetEntity="Aqarmap\Bundle\ListingBundle\Entity\ListingRate", mappedBy="listing", fetch="EXTRA_LAZY")
  781.      */
  782.     private $rates;
  783.     /**
  784.      * @var int
  785.      */
  786.     private $totalRates;
  787.     /**
  788.      * @var ArrayCollection
  789.      */
  790.     private $rateReasonsCollection;
  791.     /**
  792.      * @ORM\Column(name="synced", type="boolean")
  793.      */
  794.     private $synced false;
  795.     /**
  796.      * @ORM\Column(name="reference_id", type="integer", nullable=true)
  797.      */
  798.     private $referenceId;
  799.     private $featuredTypeLabel;
  800.     /**
  801.      * @ORM\OneToMany(targetEntity="Aqarmap\Bundle\ListingBundle\Entity\Favourite", mappedBy="listing")
  802.      */
  803.     protected $favourite;
  804.     /**
  805.      * @ORM\OneToMany(targetEntity="Aqarmap\Bundle\ValueEngineBundle\Entity\ValueEngineListingsLocations", mappedBy="listing")
  806.      **/
  807.     protected $valueEngineListingsLocations;
  808.     /**
  809.      * @ORM\Column(name="is_pending_featuring", type="boolean", nullable=true)
  810.      */
  811.     private $isPendingFeaturing false;
  812.     /**
  813.      * @ORM\Column(name="pending_featuring_type", type="integer", nullable=true)
  814.      */
  815.     private $pendingFeaturingType;
  816.     /**
  817.      * @ORM\OneToMany(targetEntity="Aqarmap\Bundle\ListingBundle\Entity\ListingNote", mappedBy="listing")
  818.      */
  819.     protected $notes;
  820.     /**
  821.      * @var bool
  822.      */
  823.     private $isFavourite false;
  824.     /**
  825.      * @var string
  826.      */
  827.     private $userNote;
  828.     /**
  829.      * @ORM\Column(name="rate_status", type="smallint", nullable=true)
  830.      */
  831.     private $rateStatus;
  832.     /**
  833.      * @ORM\Column(name="is_rate_reviewed", type="boolean", nullable=true, options={"default" = 0})
  834.      */
  835.     private $isRateReviewed false;
  836.     /**
  837.      * @ORM\Column(name="is_call_request", type="boolean", options={"default" = 0})
  838.      *
  839.      * @Serializer\SerializedName("isCallRequest")
  840.      *
  841.      * @Serializer\Groups({"List", "Details", "Search", "DefaultV4", "SearchV4","ProjectDetailsV4", "RelatedListingsV2", "listingDetails"})
  842.      *
  843.      * @Serializer\Expose
  844.      */
  845.     private $isCallRequest false;
  846.     /**
  847.      * @ORM\Column(name="is_shown_in_homepage", type="boolean", options={"default" = 0})
  848.      *
  849.      * @Serializer\Groups({"List", "Details", "DefaultV4"})
  850.      *
  851.      * @Serializer\Expose
  852.      */
  853.     private $isShownInHomepage false;
  854.     /**
  855.      * @var DateTime
  856.      */
  857.     private $reportedDate;
  858.     /**
  859.      * @var Listing
  860.      */
  861.     private $parentOfSimilarListing;
  862.     /**
  863.      * @Serializer\SerializedName("attributes")
  864.      *
  865.      * @Serializer\Groups({"NotesDetails"})
  866.      *
  867.      * @Serializer\Expose()
  868.      */
  869.     private $listingAttributes = [];
  870.     /**
  871.      * TODO:This Field Is maily Related To Compounds Will Be removed with new project compounds Valu.
  872.      *
  873.      * @var int
  874.      *
  875.      * @ORM\Column(name="is_commercial", type="smallint", nullable=true)
  876.      */
  877.     private $isCommercial false;
  878.     /**
  879.      * @var array
  880.      */
  881.     private $mappedPhotos = [];
  882.     /**
  883.      * @var array
  884.      */
  885.     private $v4Translations = [];
  886.     private ?array $mappedMainPhoto null;
  887.     /**
  888.      * @var bool
  889.      *
  890.      * @ORM\Column(name="is_resale", type="boolean", options={"default" = 0})
  891.      *
  892.      * @Serializer\SerializedName("isResale")
  893.      *
  894.      * @Serializer\Groups({"List", "Details", "Search", "DefaultV4", "SearchV4", "ProjectDetailsV4"})
  895.      *
  896.      * @Serializer\Expose
  897.      */
  898.     private $isResale false;
  899.     /**
  900.      * @var bool
  901.      *
  902.      * @ORM\Column(name="is_rent", type="boolean", options={"default" = 0})
  903.      *
  904.      * @Serializer\SerializedName("isRent")
  905.      *
  906.      * @Serializer\Groups({"List", "Details", "Search", "DefaultV4", "SearchV4", "ProjectDetailsV4"})
  907.      *
  908.      * @Serializer\Expose
  909.      */
  910.     private $isRent false;
  911.     /**
  912.      * @var bool
  913.      *
  914.      * @ORM\Column(name="is_primary", type="boolean", options={"default" = 0})
  915.      *
  916.      * @Serializer\SerializedName("isPrimary")
  917.      *
  918.      * @Serializer\Groups({"List", "Details", "Search", "DefaultV4", "SearchV4", "ProjectDetailsV4"})
  919.      *
  920.      * @Serializer\Expose
  921.      */
  922.     private $isPrimary false;
  923.     /**
  924.      * @var bool
  925.      *
  926.      * @ORM\Column(name="is_mortgage_approved", type="boolean", nullable=true)
  927.      *
  928.      * @Serializer\SerializedName("isMortgageApproved")
  929.      *
  930.      * @Serializer\Groups({"List", "Details", "Search", "DefaultV4", "SearchV4", "listingDetails"})
  931.      *
  932.      * @Serializer\Expose
  933.      */
  934.     private $isMortgageApproved;
  935.     /**
  936.      * @ORM\OneToMany(targetEntity="Aqarmap\Bundle\ListingBundle\Entity\ListingsRatesNote", mappedBy="listing")
  937.      *
  938.      * @Serializer\Groups({"List", "Details"})
  939.      *
  940.      * @Serializer\Expose
  941.      */
  942.     private $ratesNotes = [];
  943.     /**
  944.      * @var string
  945.      *
  946.      * @ORM\Column(name="meta_title", type="string", length=128, nullable=true)
  947.      *
  948.      * @Gedmo\Translatable
  949.      */
  950.     private $metaTitle;
  951.     /**
  952.      * @var string
  953.      *
  954.      * @ORM\Column(name="meta_description", type="text", length=1024, nullable=true)
  955.      *
  956.      * @Gedmo\Translatable
  957.      */
  958.     private $metaDescription;
  959.     /**
  960.      * @var bool
  961.      *
  962.      * @ORM\Column(name="is_mortgage", type="boolean", options={"default" = 0})
  963.      *
  964.      * @Serializer\SerializedName("isMortgage")
  965.      *
  966.      * @Serializer\Groups({"List", "Details", "Search", "DefaultV4", "SearchV4", "RelatedListingsV2"})
  967.      *
  968.      * @Serializer\Expose
  969.      */
  970.     private $isMortgage false;
  971.     /**
  972.      * @var CompoundField
  973.      *
  974.      * @ORM\OneToOne(targetEntity="Aqarmap\Bundle\ListingBundle\Entity\CompoundField")
  975.      *
  976.      * @ORM\JoinColumn(name="compound_field_id", referencedColumnName="id")
  977.      */
  978.     protected $compoundField;
  979.     /** @var array
  980.      *
  981.      * @ORM\Column(name="eligible_for_mortgage", type="array", nullable=true)
  982.      */
  983.     private $eligibleForMortgage;
  984.     /**
  985.      * @var array
  986.      */
  987.     private $propertyRegistrationStatusOptions;
  988.     /**
  989.      * @var array
  990.      */
  991.     private $eligibleForMortgageData;
  992.     /**
  993.      * property Registration Status , default I'm not know = 4.
  994.      *
  995.      * @var int
  996.      *
  997.      * @ORM\Column(name="property_registration_status", type="integer", nullable=true ,options={"default" = 4})
  998.      *
  999.      * @Serializer\SerializedName("propertyRegistrationStatus")
  1000.      *
  1001.      * @Serializer\Groups({"List", "Details", "Search", "DefaultV4", "SearchV4"})
  1002.      *
  1003.      * @Serializer\Expose
  1004.      */
  1005.     private $propertyRegistrationStatus;
  1006.     /**
  1007.      * @var array
  1008.      *
  1009.      * @Serializer\SerializedName("propertyTypeChildren")
  1010.      *
  1011.      * @Serializer\Groups({"ProjectDetailsV4"})
  1012.      *
  1013.      * @Serializer\Expose
  1014.      */
  1015.     private $propertyTypeChilden = [];
  1016.     /**
  1017.      * @var float
  1018.      */
  1019.     private $compoundElasticScore;
  1020.     /**
  1021.      * @var FinancialAid
  1022.      */
  1023.     private $financialAid;
  1024.     /**
  1025.      * @deprecated It's bad design, and cause a performance issues
  1026.      */
  1027.     private int $similarListingsCount 0;
  1028.     /**
  1029.      * @deprecated It's bad design, and cause a performance issues
  1030.      */
  1031.     private array $similarListingsIds = [];
  1032.     /**
  1033.      * @var string|null
  1034.      *
  1035.      * @ORM\Column(name="advertiser_number", type="string", nullable=true)
  1036.      *
  1037.      * @Serializer\SerializedName("advertiserNumber")
  1038.      *
  1039.      * @Serializer\Groups({"List", "Details", "Search", "DefaultV4", "SearchV4"})
  1040.      *
  1041.      * @Serializer\Expose
  1042.      */
  1043.     private $advertiserNumber;
  1044.     /**
  1045.      * @var string|null
  1046.      *
  1047.      * @ORM\Column(name="authorization_number", type="string", nullable=true)
  1048.      *
  1049.      * @Serializer\SerializedName("authorizationNumber")
  1050.      *
  1051.      * @Serializer\Groups({"List", "Details", "Search", "DefaultV4", "SearchV4"})
  1052.      *
  1053.      * @Serializer\Expose
  1054.      */
  1055.     private $authorizationNumber;
  1056.     /**
  1057.      * @var float
  1058.      */
  1059.     private $costPerLead 0;
  1060.     /**
  1061.      * @Serializer\Groups({"ProjectDetailsV4"})
  1062.      *
  1063.      * @Serializer\SerializedName("resaleCount")
  1064.      *
  1065.      * @Serializer\Expose
  1066.      */
  1067.     private $resaleCount 0;
  1068.     /**
  1069.      * @Serializer\Groups({ "ProjectDetailsV4"})
  1070.      *
  1071.      * @Serializer\SerializedName("rentCount")
  1072.      *
  1073.      * @Serializer\Expose
  1074.      */
  1075.     private $rentCount 0;
  1076.     /**
  1077.      * @var \DateTime
  1078.      *
  1079.      * @ORM\Column(name="freezed_at", type="datetime", nullable=true)
  1080.      */
  1081.     private $freezedAt;
  1082.     /**
  1083.      * @ORM\Column(name="eligible_for_bumpup", type="boolean", options={"default" = 0})
  1084.      */
  1085.     private $eligibleForBumpUp false;
  1086.     /**
  1087.      * @ORM\Column(name="waiting_time", type="string", length=50, nullable=true)
  1088.      *
  1089.      * @var string
  1090.      */
  1091.     private $waitingTime;
  1092.     /**
  1093.      * @ORM\Column(name="reference_number", type="string", length=128, nullable=true)
  1094.      *
  1095.      * @Serializer\Groups({"MyListing", "MyListings", "listingDetails", "MyLeads"})
  1096.      *
  1097.      * @Serializer\Expose
  1098.      */
  1099.     private ?string $referenceNumber null;
  1100.     /**
  1101.      * @Serializer\Groups({"SearchV4"})
  1102.      *
  1103.      * @Serializer\Expose
  1104.      */
  1105.     public $debug;
  1106.     /**
  1107.      * @var File|null
  1108.      *
  1109.      * @ORM\OneToOne(targetEntity="Aqarmap\Bundle\ListingBundle\Entity\File", cascade={"persist", "remove"})
  1110.      *
  1111.      * @ORM\JoinColumn(name="brochure_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  1112.      *
  1113.      * @Serializer\Groups({"Default", "DefaultV4","ProjectSearchV4", "ProjectDetailsV4", "locationListingV2"})
  1114.      *
  1115.      * @Serializer\Expose
  1116.      */
  1117.     private $brochure;
  1118.     /**
  1119.      * Constructor.
  1120.      */
  1121.     public function __construct()
  1122.     {
  1123.         $this->children = new ArrayCollection();
  1124.         $this->attributes = new ArrayCollection();
  1125.         $this->phones = new ArrayCollection();
  1126.         $this->photos = new ArrayCollection();
  1127.         $this->leads = new ArrayCollection();
  1128.         $this->rates = new ArrayCollection();
  1129.         $this->listingFeatures = new ArrayCollection();
  1130.         $this->ListingNotifications = new ArrayCollection();
  1131.         $this->translations = new ArrayCollection();
  1132.         $this->rejections = new ArrayCollection();
  1133.         $this->participants = new ArrayCollection();
  1134.         $this->rateReasonsCollection = new ArrayCollection();
  1135.         $this->favourite = new ArrayCollection();
  1136.     }
  1137.     /**
  1138.      * Clone.
  1139.      */
  1140.     public function __clone()
  1141.     {
  1142.         $this->id null;
  1143.         $this->slug null;
  1144.         $this->children null;
  1145.         $this->title null;
  1146.         $this->address null;
  1147.         $this->description null;
  1148.         $this->translations null;
  1149.         $this->leads = new ArrayCollection();
  1150.         $this->participants null;
  1151.         $this->featured 0;
  1152.         $this->views 0;
  1153.         $this->customSlug null;
  1154.         $this->relistCounter 0;
  1155.         $this->messagesCounter 0;
  1156.         $this->phoneCounter 0;
  1157.         $this->sentNotifiers 0;
  1158.         $this->isBumped false;
  1159.         $this->ratesNotes = new ArrayCollection();
  1160.         $this->compoundField null;
  1161.         $this->compoundAveragePrices null;
  1162.     }
  1163.     /**
  1164.      * @ORM\PrePersist
  1165.      */
  1166.     public function onPrePersist(): void
  1167.     {
  1168.         if (!$this->getCreatedAt()) {
  1169.             $this->setCreatedAt(new \DateTime());
  1170.         }
  1171.         if (!$this->getUpdatedAt()) {
  1172.             $this->setUpdatedAt(new \DateTime());
  1173.         }
  1174.     }
  1175.     /**
  1176.      * Get id.
  1177.      *
  1178.      * @return int
  1179.      */
  1180.     public function getId()
  1181.     {
  1182.         return $this->id;
  1183.     }
  1184.     /**
  1185.      * Set title.
  1186.      *
  1187.      * @param string $title
  1188.      *
  1189.      * @return Listing
  1190.      */
  1191.     public function setTitle($title)
  1192.     {
  1193.         $this->title $title;
  1194.         return $this;
  1195.     }
  1196.     /**
  1197.      * Get title.
  1198.      *
  1199.      * @return string
  1200.      */
  1201.     public function getTitle()
  1202.     {
  1203.         return $this->title;
  1204.     }
  1205.     /**
  1206.      * Set description.
  1207.      *
  1208.      * @param string $description
  1209.      *
  1210.      * @return Listing
  1211.      */
  1212.     public function setDescription($description)
  1213.     {
  1214.         $this->description $description;
  1215.         return $this;
  1216.     }
  1217.     /**
  1218.      * Get description.
  1219.      *
  1220.      * @return string
  1221.      */
  1222.     public function getDescription()
  1223.     {
  1224.         return $this->description;
  1225.     }
  1226.     /**
  1227.      * Set section.
  1228.      *
  1229.      * @return Listing
  1230.      */
  1231.     public function setSection(?Section $section null)
  1232.     {
  1233.         $this->section $section;
  1234.         return $this;
  1235.     }
  1236.     /**
  1237.      * Get section.
  1238.      *
  1239.      * @return Section
  1240.      */
  1241.     public function getSection()
  1242.     {
  1243.         return $this->section;
  1244.     }
  1245.     /**
  1246.      * Set category.
  1247.      *
  1248.      * @param int $category
  1249.      *
  1250.      * @return Listing
  1251.      */
  1252.     public function setCategory($category)
  1253.     {
  1254.         $this->category $category;
  1255.         return $this;
  1256.     }
  1257.     /**
  1258.      * Get category.
  1259.      *
  1260.      * @return int
  1261.      */
  1262.     public function getCategory()
  1263.     {
  1264.         return $this->category;
  1265.     }
  1266.     /**
  1267.      * Get category name.
  1268.      *
  1269.      * @return string
  1270.      */
  1271.     public function getCategoryName()
  1272.     {
  1273.         return ListingCategories::getLabel($this->category);
  1274.     }
  1275.     /**
  1276.      * @return bool
  1277.      */
  1278.     public function isDraft()
  1279.     {
  1280.         return ListingStatus::DRAFT == $this->status;
  1281.     }
  1282.     /**
  1283.      * @return bool
  1284.      */
  1285.     public function isLive()
  1286.     {
  1287.         return ListingStatus::LIVE == $this->status;
  1288.     }
  1289.     /**
  1290.      * Set pendingPhotosStatus.
  1291.      *
  1292.      * @param int $pendingPhotosStatus
  1293.      *
  1294.      * @return Listing
  1295.      */
  1296.     public function setPendingPhotosStatus($pendingPhotosStatus)
  1297.     {
  1298.         $this->pendingPhotosStatus $pendingPhotosStatus;
  1299.         return $this;
  1300.     }
  1301.     /**
  1302.      * Get pendingPhotosStatus.
  1303.      *
  1304.      * @return int
  1305.      */
  1306.     public function getPendingPhotosStatus()
  1307.     {
  1308.         return $this->pendingPhotosStatus;
  1309.     }
  1310.     /**
  1311.      * Set pendingPaymentStatus.
  1312.      *
  1313.      * @param int $pendingPaymentStatus
  1314.      *
  1315.      * @return Listing
  1316.      */
  1317.     public function setPendingPaymentStatus($pendingPaymentStatus)
  1318.     {
  1319.         $this->pendingPaymentStatus $pendingPaymentStatus;
  1320.         return $this;
  1321.     }
  1322.     /**
  1323.      * Get pendingPaymentStatus.
  1324.      *
  1325.      * @return int
  1326.      */
  1327.     public function getPendingPaymentStatus()
  1328.     {
  1329.         return $this->pendingPaymentStatus;
  1330.     }
  1331.     /**
  1332.      * Set relistStatus.
  1333.      *
  1334.      * @param int $relistStatus
  1335.      *
  1336.      * @return Listing
  1337.      */
  1338.     public function setRelistStatus($relistStatus)
  1339.     {
  1340.         $this->relistStatus $relistStatus;
  1341.         return $this;
  1342.     }
  1343.     /**
  1344.      * Get relistStatus.
  1345.      *
  1346.      * @return int
  1347.      */
  1348.     public function getRelistStatus()
  1349.     {
  1350.         return $this->relistStatus;
  1351.     }
  1352.     /**
  1353.      * Set sellerRole.
  1354.      */
  1355.     public function setSellerRole(?int $sellerRole): self
  1356.     {
  1357.         $this->sellerRole $sellerRole;
  1358.         return $this;
  1359.     }
  1360.     /**
  1361.      * Get sellerRole.
  1362.      */
  1363.     public function getSellerRole(): ?int
  1364.     {
  1365.         return $this->sellerRole;
  1366.     }
  1367.     /**
  1368.      * @Serializer\VirtualProperty
  1369.      *
  1370.      * @Serializer\SerializedName("seller_role")
  1371.      *
  1372.      * @Serializer\Groups({"List", "Details", "listingDetails"})
  1373.      *
  1374.      * @Serializer\Until("v2.0")
  1375.      *
  1376.      * @return string
  1377.      */
  1378.     public function getSellerRoleLabel()
  1379.     {
  1380.         return ListingSellerRoles::getLabel($this->getSellerRole());
  1381.     }
  1382.     public function setSellerRoleLabel($label): void
  1383.     {
  1384.         $this->sellerRoleLabel $label;
  1385.     }
  1386.     /**
  1387.      * @Serializer\VirtualProperty
  1388.      *
  1389.      * @Serializer\SerializedName("seller_role_label")
  1390.      *
  1391.      * @Serializer\Groups({"List", "Details"})
  1392.      *
  1393.      * @Serializer\Since("v2.1")
  1394.      *
  1395.      * @Serializer\Until("v2.11")
  1396.      *
  1397.      * @return string
  1398.      */
  1399.     public function getSellerRoleAsLabel()
  1400.     {
  1401.         return self::getSellerRoleLabel();
  1402.     }
  1403.     /**
  1404.      * @Serializer\VirtualProperty
  1405.      *
  1406.      * @Serializer\SerializedName("seller_role_label")
  1407.      *
  1408.      * @Serializer\Groups({"List", "Details", "DefaultV4"})
  1409.      *
  1410.      * @Serializer\Since("v2.12")
  1411.      *
  1412.      * @return string
  1413.      */
  1414.     public function getSellerRoleTranslated()
  1415.     {
  1416.         return $this->sellerRoleLabel;
  1417.     }
  1418.     /**
  1419.      * @Serializer\VirtualProperty
  1420.      *
  1421.      * @Serializer\SerializedName("accepts_messages")
  1422.      *
  1423.      * @Serializer\Groups({"List", "Details", "listingDetails"})
  1424.      *
  1425.      * @return bool
  1426.      */
  1427.     public function isAcceptsMessages()
  1428.     {
  1429.         return !$this->getUser()->hasRole('ROLE_TROOP');
  1430.     }
  1431.     /**
  1432.      * Set area.
  1433.      *
  1434.      * @param int $area
  1435.      *
  1436.      * @return Listing
  1437.      */
  1438.     public function setArea($area)
  1439.     {
  1440.         $this->area $area;
  1441.         return $this;
  1442.     }
  1443.     /**
  1444.      * Get area.
  1445.      *
  1446.      * @return int
  1447.      */
  1448.     public function getArea()
  1449.     {
  1450.         return (int) $this->area;
  1451.     }
  1452.     /**
  1453.      * Set price.
  1454.      *
  1455.      * @return Listing
  1456.      */
  1457.     public function setPrice(?int $price)
  1458.     {
  1459.         $this->price $price;
  1460.         return $this;
  1461.     }
  1462.     /**
  1463.      * Get price.
  1464.      */
  1465.     public function getPrice(): ?int
  1466.     {
  1467.         return $this->price;
  1468.     }
  1469.     /**
  1470.      * Set address.
  1471.      *
  1472.      * @param string $address
  1473.      *
  1474.      * @return Listing
  1475.      */
  1476.     public function setAddress($address)
  1477.     {
  1478.         $this->address $address;
  1479.         return $this;
  1480.     }
  1481.     /**
  1482.      * Get address.
  1483.      *
  1484.      * @return string
  1485.      */
  1486.     public function getAddress()
  1487.     {
  1488.         return $this->address;
  1489.     }
  1490.     /**
  1491.      * Set centerLat.
  1492.      *
  1493.      * @param float $centerLat
  1494.      *
  1495.      * @return Listing
  1496.      */
  1497.     public function setCenterLat($centerLat)
  1498.     {
  1499.         $this->centerLat $centerLat;
  1500.         return $this;
  1501.     }
  1502.     /**
  1503.      * Get centerLat.
  1504.      *
  1505.      * @return float
  1506.      */
  1507.     public function getCenterLat()
  1508.     {
  1509.         return $this->centerLat;
  1510.     }
  1511.     /**
  1512.      * Set centerLng.
  1513.      *
  1514.      * @param float $centerLng
  1515.      *
  1516.      * @return Listing
  1517.      */
  1518.     public function setCenterLng($centerLng)
  1519.     {
  1520.         $this->centerLng $centerLng;
  1521.         return $this;
  1522.     }
  1523.     /**
  1524.      * Get centerLng.
  1525.      *
  1526.      * @return float
  1527.      */
  1528.     public function getCenterLng()
  1529.     {
  1530.         return $this->centerLng;
  1531.     }
  1532.     /**
  1533.      * Set featured.
  1534.      *
  1535.      * @param int $featured
  1536.      *
  1537.      * @return Listing
  1538.      */
  1539.     public function setFeatured($featured)
  1540.     {
  1541.         $this->featured $featured;
  1542.         return $this;
  1543.     }
  1544.     /**
  1545.      * Get featured.
  1546.      *
  1547.      * @return int
  1548.      */
  1549.     public function getFeatured()
  1550.     {
  1551.         return $this->featured;
  1552.     }
  1553.     /**
  1554.      * @Serializer\VirtualProperty
  1555.      *
  1556.      * @Serializer\SerializedName("is_featured")
  1557.      *
  1558.      * @Serializer\Groups({"List", "Details", "DataLayer", "MyListing", "MyListings", "listingDetails"})
  1559.      *
  1560.      * @return bool
  1561.      */
  1562.     public function isFeatured()
  1563.     {
  1564.         return (bool) $this->getFeatured();
  1565.     }
  1566.     /**
  1567.      * @Serializer\VirtualProperty
  1568.      *
  1569.      * @Serializer\SerializedName("isFeatured")
  1570.      *
  1571.      * @Serializer\Groups({"DefaultV4", "SearchV4"})
  1572.      *
  1573.      * @return bool
  1574.      */
  1575.     public function getFeaturingStatus()
  1576.     {
  1577.         return (bool) $this->getFeatured();
  1578.     }
  1579.     /**
  1580.      * @return string
  1581.      */
  1582.     public function getFeaturedLabel()
  1583.     {
  1584.         return ListingFeaturedTypes::getLabel($this->getFeatured());
  1585.     }
  1586.     /**
  1587.      * Set views.
  1588.      *
  1589.      * @param int $views
  1590.      *
  1591.      * @return Listing
  1592.      */
  1593.     public function setViews($views)
  1594.     {
  1595.         $this->views $views;
  1596.         return $this;
  1597.     }
  1598.     /**
  1599.      * Get views.
  1600.      *
  1601.      * @return int
  1602.      */
  1603.     public function getViews()
  1604.     {
  1605.         return $this->views $this->views 0;
  1606.     }
  1607.     /**
  1608.      * Get views count.
  1609.      *
  1610.      * @return int
  1611.      */
  1612.     public function getTotalViews()
  1613.     {
  1614.         $totalViews $this->getViews();
  1615.         if ($this->getChildren()) {
  1616.             foreach ($this->getChildren() as $listing) {
  1617.                 $totalViews += $listing->getViews();
  1618.             }
  1619.         }
  1620.         return $totalViews;
  1621.     }
  1622.     /**
  1623.      * Set relistCounter.
  1624.      *
  1625.      * @param int $relistCounter
  1626.      *
  1627.      * @return Listing
  1628.      */
  1629.     public function setRelistCounter($relistCounter)
  1630.     {
  1631.         $this->relistCounter $relistCounter;
  1632.         return $this;
  1633.     }
  1634.     /**
  1635.      * Get relistCounter.
  1636.      *
  1637.      * @return int
  1638.      */
  1639.     public function getRelistCounter()
  1640.     {
  1641.         return $this->relistCounter;
  1642.     }
  1643.     /**
  1644.      * Set sentNotifiers.
  1645.      *
  1646.      * @param int $sentNotifiers
  1647.      *
  1648.      * @return Listing
  1649.      */
  1650.     public function setSentNotifiers($sentNotifiers)
  1651.     {
  1652.         $this->sentNotifiers $sentNotifiers;
  1653.         return $this;
  1654.     }
  1655.     /**
  1656.      * Get sentNotifiers.
  1657.      *
  1658.      * @return int
  1659.      */
  1660.     public function getSentNotifiers()
  1661.     {
  1662.         return $this->sentNotifiers;
  1663.     }
  1664.     /**
  1665.      * Set status.
  1666.      *
  1667.      * @param int $status
  1668.      *
  1669.      * @return Listing
  1670.      */
  1671.     public function setStatus($status)
  1672.     {
  1673.         $this->status $status;
  1674.         return $this;
  1675.     }
  1676.     /**
  1677.      * Get status.
  1678.      *
  1679.      * @return int
  1680.      */
  1681.     public function getStatus()
  1682.     {
  1683.         return $this->status;
  1684.     }
  1685.     /**
  1686.      * @Serializer\VirtualProperty
  1687.      *
  1688.      * @Serializer\SerializedName("status_label")
  1689.      *
  1690.      * @Serializer\Groups({"List", "Details", "listingDetails"})
  1691.      *
  1692.      * @Serializer\Until("v2.11")
  1693.      *
  1694.      * @return string
  1695.      */
  1696.     public function getStatusLabel()
  1697.     {
  1698.         return ListingStatus::getLabel($this->getStatus());
  1699.     }
  1700.     /**
  1701.      * @Serializer\VirtualProperty
  1702.      *
  1703.      * @Serializer\SerializedName("status_label")
  1704.      *
  1705.      * @Serializer\Groups({"List", "Details"})
  1706.      *
  1707.      * @Serializer\Since("v2.12")
  1708.      *
  1709.      * @return string
  1710.      */
  1711.     public function getStatusTranslated()
  1712.     {
  1713.         return $this->statusLabel;
  1714.     }
  1715.     public function setStatusLabel($label): void
  1716.     {
  1717.         $this->statusLabel $label;
  1718.     }
  1719.     /**
  1720.      * @return string
  1721.      */
  1722.     public function getStatusDescription()
  1723.     {
  1724.         return ListingStatus::getDescription($this->getStatus());
  1725.     }
  1726.     /**
  1727.      * Set ip.
  1728.      *
  1729.      * @param string $ip
  1730.      *
  1731.      * @return Listing
  1732.      */
  1733.     public function setIp($ip)
  1734.     {
  1735.         $this->ip $ip;
  1736.         return $this;
  1737.     }
  1738.     /**
  1739.      * Get ip.
  1740.      *
  1741.      * @return string
  1742.      */
  1743.     public function getIp()
  1744.     {
  1745.         return $this->ip;
  1746.     }
  1747.     /**
  1748.      * @param string $videoUrl
  1749.      *
  1750.      * @return $this
  1751.      */
  1752.     public function setVideoUrl($videoUrl)
  1753.     {
  1754.         $this->videoUrl $videoUrl;
  1755.         return $this;
  1756.     }
  1757.     /**
  1758.      * @return string
  1759.      */
  1760.     public function getVideoUrl()
  1761.     {
  1762.         return $this->videoUrl;
  1763.     }
  1764.     /**
  1765.      * Set slug.
  1766.      *
  1767.      * @param string $slug
  1768.      *
  1769.      * @return Listing
  1770.      */
  1771.     public function setSlug($slug)
  1772.     {
  1773.         $this->slug $slug;
  1774.         return $this;
  1775.     }
  1776.     /**
  1777.      * Get slug.
  1778.      *
  1779.      * @return string
  1780.      */
  1781.     public function getSlug()
  1782.     {
  1783.         return $this->slug;
  1784.     }
  1785.     /**
  1786.      * Set customSlug.
  1787.      *
  1788.      * @param string $customSlug
  1789.      *
  1790.      * @return Listing
  1791.      */
  1792.     public function setCustomSlug($customSlug)
  1793.     {
  1794.         $this->customSlug str_replace(' ''-'strtolower($customSlug));
  1795.         return $this;
  1796.     }
  1797.     /**
  1798.      * Get customSlug.
  1799.      *
  1800.      * @param bool $force
  1801.      *
  1802.      * @return string
  1803.      */
  1804.     public function getCustomSlug($force false)
  1805.     {
  1806.         if ($force && empty($this->customSlug)) {
  1807.             return $this->slug;
  1808.         }
  1809.         return $this->customSlug;
  1810.     }
  1811.     /**
  1812.      * Set score.
  1813.      *
  1814.      * @param float $score
  1815.      *
  1816.      * @return Listing
  1817.      */
  1818.     public function setScore($score)
  1819.     {
  1820.         $this->score $score;
  1821.         return $this;
  1822.     }
  1823.     /**
  1824.      * Get score.
  1825.      *
  1826.      * @return float
  1827.      */
  1828.     public function getScore()
  1829.     {
  1830.         return $this->score;
  1831.     }
  1832.     /**
  1833.      * Set maxPrice.
  1834.      *
  1835.      * @param int $maxPrice
  1836.      *
  1837.      * @return Listing
  1838.      */
  1839.     public function setMaxPrice($maxPrice)
  1840.     {
  1841.         $this->maxPrice $maxPrice;
  1842.         return $this;
  1843.     }
  1844.     /**
  1845.      * Get maxPrice.
  1846.      *
  1847.      * @return int
  1848.      */
  1849.     public function getMaxPrice()
  1850.     {
  1851.         return $this->maxPrice;
  1852.     }
  1853.     /**
  1854.      * Set createdAt.
  1855.      *
  1856.      * @param \DateTime $createdAt
  1857.      *
  1858.      * @return Listing
  1859.      */
  1860.     public function setCreatedAt($createdAt)
  1861.     {
  1862.         $this->createdAt $createdAt;
  1863.         return $this;
  1864.     }
  1865.     /**
  1866.      * Get createdAt.
  1867.      *
  1868.      * @Serializer\VirtualProperty()
  1869.      *
  1870.      * @Serializer\Groups({"MyListing"})
  1871.      *
  1872.      * @Serializer\Expose
  1873.      *
  1874.      * @return \DateTime
  1875.      */
  1876.     public function getCreatedAt()
  1877.     {
  1878.         return $this->createdAt;
  1879.     }
  1880.     /**
  1881.      * Set updatedAt.
  1882.      *
  1883.      * @param \DateTime $updatedAt
  1884.      *
  1885.      * @return Listing
  1886.      */
  1887.     public function setUpdatedAt($updatedAt)
  1888.     {
  1889.         $this->updatedAt $updatedAt;
  1890.         return $this;
  1891.     }
  1892.     /**
  1893.      * Get updatedAt.
  1894.      *
  1895.      * @return \DateTime
  1896.      */
  1897.     public function getUpdatedAt()
  1898.     {
  1899.         return $this->updatedAt;
  1900.     }
  1901.     /**
  1902.      * Set pendingStatusCreatedAt.
  1903.      *
  1904.      * @param \DateTime $pendingStatusCreatedAt
  1905.      *
  1906.      * @return Listing
  1907.      */
  1908.     public function setPendingStatusCreatedAt($pendingStatusCreatedAt)
  1909.     {
  1910.         $this->pendingStatusCreatedAt $pendingStatusCreatedAt;
  1911.         return $this;
  1912.     }
  1913.     /**
  1914.      * Get pendingStatusCreatedAt.
  1915.      *
  1916.      * @return \DateTime
  1917.      */
  1918.     public function getPendingStatusCreatedAt()
  1919.     {
  1920.         return $this->pendingStatusCreatedAt;
  1921.     }
  1922.     /**
  1923.      * Set publishedAt.
  1924.      *
  1925.      * @return Listing
  1926.      */
  1927.     public function setPublishedAt(?\DateTime $publishedAt null)
  1928.     {
  1929.         $this->publishedAt $publishedAt;
  1930.         return $this;
  1931.     }
  1932.     /**
  1933.      * Get publishedAt.
  1934.      *
  1935.      * @return \DateTime
  1936.      */
  1937.     public function getPublishedAt()
  1938.     {
  1939.         return $this->publishedAt;
  1940.     }
  1941.     /**
  1942.      * @Serializer\VirtualProperty()
  1943.      *
  1944.      * @return \DateTime|ArrayCollection|Collection
  1945.      */
  1946.     public function getAggregatedPublishedAt()
  1947.     {
  1948.         $lastBump $this->getLastAutoBumpUp();
  1949.         /** @var ListingFeature $lastFeature */
  1950.         $lastFeature $this->getLastListingFeature();
  1951.         $listingFeature null;
  1952.         if ($lastBump && $lastFeature) {
  1953.             $listingFeature = ($lastBump->getLastBumpedAt() > $lastFeature->getCreatedAt()) ? $lastBump $lastFeature;
  1954.         } elseif ($lastBump) {
  1955.             $listingFeature $lastBump;
  1956.         } elseif ($lastFeature) {
  1957.             $listingFeature $lastFeature;
  1958.         }
  1959.         if (!$listingFeature) {
  1960.             return $this->getPublishedAt();
  1961.         }
  1962.         return (ListingFeatures::BUMP_UP == $listingFeature->getType() && $listingFeature->getLastBumpedAt()) ?
  1963.             $listingFeature->getLastBumpedAt() : $listingFeature->getCreatedAt();
  1964.     }
  1965.     /**
  1966.      * Set expiresAt.
  1967.      *
  1968.      * @param \DateTime $expiresAt
  1969.      *
  1970.      * @return Listing
  1971.      */
  1972.     public function setExpiresAt($expiresAt)
  1973.     {
  1974.         $this->expiresAt $expiresAt;
  1975.         return $this;
  1976.     }
  1977.     /**
  1978.      * Get expiresAt.
  1979.      *
  1980.      * @return \DateTime
  1981.      */
  1982.     public function getExpiresAt()
  1983.     {
  1984.         return $this->expiresAt;
  1985.     }
  1986.     public function setDeletedAt(?\DateTime $deletedAt): Listing
  1987.     {
  1988.         $this->deletedAt $deletedAt;
  1989.         return $this;
  1990.     }
  1991.     /**
  1992.      * Get deletedAt.
  1993.      *
  1994.      * @return \DateTime
  1995.      */
  1996.     public function getDeletedAt()
  1997.     {
  1998.         return $this->deletedAt;
  1999.     }
  2000.     /**
  2001.      * Set rejectedAt.
  2002.      *
  2003.      * @param \DateTime $rejectedAt
  2004.      *
  2005.      * @return Listing
  2006.      */
  2007.     public function setRejectedAt($rejectedAt)
  2008.     {
  2009.         $this->rejectedAt $rejectedAt;
  2010.         return $this;
  2011.     }
  2012.     /**
  2013.      * Get rejectedAt.
  2014.      *
  2015.      * @return \DateTime
  2016.      */
  2017.     public function getRejectedAt()
  2018.     {
  2019.         return $this->rejectedAt;
  2020.     }
  2021.     /**
  2022.      * Add children.
  2023.      *
  2024.      * @return Listing
  2025.      */
  2026.     public function addChild(self $children)
  2027.     {
  2028.         $this->children[] = $children;
  2029.         return $this;
  2030.     }
  2031.     /**
  2032.      * Remove children.
  2033.      */
  2034.     public function removeChild(self $children): void
  2035.     {
  2036.         $this->children->removeElement($children);
  2037.     }
  2038.     /**
  2039.      * Get children.
  2040.      *
  2041.      * @return Collection
  2042.      */
  2043.     public function getChildren()
  2044.     {
  2045.         $criteria Criteria::create()
  2046.             ->orderBy(['id' => Criteria::ASC]);
  2047.         if (!$this->children) {
  2048.             return null;
  2049.         }
  2050.         return $this->children->matching($criteria);
  2051.     }
  2052.     /**
  2053.      * Get only live listing children (live units) and order by area.
  2054.      */
  2055.     public function getLiveChildren(?PropertyType $propertyType null)
  2056.     {
  2057.         $criteria Criteria::create()->where(Criteria::expr()->eq('status'ListingStatus::LIVE));
  2058.         if ($propertyType) {
  2059.             $criteria->where(Criteria::expr()->eq('propertyType'$propertyType));
  2060.         }
  2061.         $criteria->orderBy(['area' => Criteria::ASC]);
  2062.         if (empty($this->children)) {
  2063.             return null;
  2064.         }
  2065.         return $this->children->matching($criteria);
  2066.     }
  2067.     public function getLiveChildrenIDs()
  2068.     {
  2069.         $ids = [];
  2070.         foreach ($this->getLiveChildren() as $listing) {
  2071.             $ids[] = $listing->getId();
  2072.         }
  2073.         return $ids;
  2074.     }
  2075.     /**
  2076.      * Get only pending listing children (live units) and order by area.
  2077.      */
  2078.     public function getPendingChildren()
  2079.     {
  2080.         $criteria Criteria::create()
  2081.             ->where(Criteria::expr()->in('status'ListingStatus::$pendingStatusArray))
  2082.             ->orderBy(['area' => Criteria::ASC]);
  2083.         return $this->children->matching($criteria);
  2084.     }
  2085.     /**
  2086.      * Set parent.
  2087.      *
  2088.      * @return Listing
  2089.      */
  2090.     public function setParent(?self $parent null)
  2091.     {
  2092.         $this->parent $parent;
  2093.         return $this;
  2094.     }
  2095.     /**
  2096.      * Get parent.
  2097.      *
  2098.      * @return Listing
  2099.      */
  2100.     public function getParent()
  2101.     {
  2102.         return $this->parent;
  2103.     }
  2104.     /**
  2105.      * Get Relist Parent.
  2106.      *
  2107.      * @return Listing
  2108.      */
  2109.     public function getRelistParent()
  2110.     {
  2111.         return $this->relistParent;
  2112.     }
  2113.     public function setRelistParent(self $relistParent): void
  2114.     {
  2115.         $this->relistParent $relistParent;
  2116.     }
  2117.     /**
  2118.      * Set propertyType.
  2119.      *
  2120.      * @return Listing
  2121.      */
  2122.     public function setPropertyType(?PropertyType $propertyType null)
  2123.     {
  2124.         $this->propertyType $propertyType;
  2125.         return $this;
  2126.     }
  2127.     /**
  2128.      * Get propertyType.
  2129.      *
  2130.      * @return PropertyType
  2131.      */
  2132.     public function getPropertyType()
  2133.     {
  2134.         return $this->propertyType;
  2135.     }
  2136.     /**
  2137.      * Set location.
  2138.      *
  2139.      * @return Listing
  2140.      */
  2141.     public function setLocation(?Location $location null)
  2142.     {
  2143.         $this->location $location;
  2144.         return $this;
  2145.     }
  2146.     /**
  2147.      * Get location.
  2148.      *
  2149.      * @return Location
  2150.      */
  2151.     public function getLocation()
  2152.     {
  2153.         return $this->location;
  2154.     }
  2155.     /**
  2156.      * Add location.
  2157.      *
  2158.      * @return Listing
  2159.      */
  2160.     public function addLocation(Location $location)
  2161.     {
  2162.         $this->locations[] = $location;
  2163.         return $this;
  2164.     }
  2165.     /**
  2166.      * Has location.
  2167.      *
  2168.      * @return bool
  2169.      */
  2170.     public function hasLocation(Location $location)
  2171.     {
  2172.         return $this->locations->contains($location);
  2173.     }
  2174.     /**
  2175.      * Set Locations.
  2176.      *
  2177.      * @return Listing
  2178.      */
  2179.     public function setLocations($locations)
  2180.     {
  2181.         foreach ($locations as $location) {
  2182.             $this->addLocation($location);
  2183.         }
  2184.         return $this;
  2185.     }
  2186.     /**
  2187.      * Remove location.
  2188.      */
  2189.     public function removeLocation(Location $location): void
  2190.     {
  2191.         $this->locations->removeElement($location);
  2192.     }
  2193.     /**
  2194.      * Get locations.
  2195.      *
  2196.      * @return Collection
  2197.      */
  2198.     public function getLocations()
  2199.     {
  2200.         return $this->locations;
  2201.     }
  2202.     /**
  2203.      * @return $this
  2204.      */
  2205.     public function setCompoundLocation(?CompoundLocation $compoundLocation null)
  2206.     {
  2207.         $this->compoundLocation $compoundLocation;
  2208.         return $this;
  2209.     }
  2210.     /**
  2211.      * @return CompoundLocation
  2212.      */
  2213.     public function getCompoundLocation()
  2214.     {
  2215.         if (!$this->compoundLocation && $this->hasParent()) {
  2216.             return $this->getParent()->getCompoundLocation();
  2217.         }
  2218.         return $this->compoundLocation;
  2219.     }
  2220.     /**
  2221.      * @return mixed|string
  2222.      */
  2223.     public function getCompoundLocationTitle()
  2224.     {
  2225.         $compoundLocation $this->getCompoundLocation();
  2226.         if ($compoundLocation instanceof CompoundLocation) {
  2227.             return $compoundLocation->getTitle();
  2228.         }
  2229.         return '';
  2230.     }
  2231.     /**
  2232.      * Set user.
  2233.      *
  2234.      * @return Listing
  2235.      */
  2236.     public function setUser(?User $user null)
  2237.     {
  2238.         $this->user $user;
  2239.         return $this;
  2240.     }
  2241.     /**
  2242.      * Get user.
  2243.      *
  2244.      * @return User
  2245.      */
  2246.     public function getUser()
  2247.     {
  2248.         return $this->user;
  2249.     }
  2250.     /**
  2251.      * Add participants.
  2252.      *
  2253.      * @return Listing
  2254.      */
  2255.     public function addParticipant(User $participants)
  2256.     {
  2257.         $this->participants[] = $participants;
  2258.         return $this;
  2259.     }
  2260.     /**
  2261.      * Remove participants.
  2262.      */
  2263.     public function removeParticipant(User $participants): void
  2264.     {
  2265.         $this->participants->removeElement($participants);
  2266.     }
  2267.     /**
  2268.      * Get participants.
  2269.      *
  2270.      * @return Collection
  2271.      */
  2272.     public function getParticipants()
  2273.     {
  2274.         return $this->participants;
  2275.     }
  2276.     /**
  2277.      * Has participant.
  2278.      *
  2279.      * @return bool
  2280.      */
  2281.     public function hasParticipant(User $participant)
  2282.     {
  2283.         $participants $this->getParticipants();
  2284.         if (\is_object($participants)) {
  2285.             return $this->getParticipants()->contains($participant) ? true false;
  2286.         }
  2287.         return false;
  2288.     }
  2289.     /**
  2290.      * @return ArrayCollection
  2291.      */
  2292.     public function getAllParticipants()
  2293.     {
  2294.         $participants = new ArrayCollection();
  2295.         $participants->add($this->getUser());
  2296.         foreach ($this->getParticipants() as $participant) {
  2297.             if (!$participants->contains($participant)) {
  2298.                 $participants->add($participant);
  2299.             }
  2300.         }
  2301.         if ($this->getParent()) {
  2302.             foreach ($this->getParent()->getAllParticipants() as $participant) {
  2303.                 if (!$participants->contains($participant)) {
  2304.                     $participants->add($participant);
  2305.                 }
  2306.             }
  2307.         }
  2308.         return $participants;
  2309.     }
  2310.     /**
  2311.      * @return ArrayCollection
  2312.      */
  2313.     public function getAllLocations()
  2314.     {
  2315.         $locations = new ArrayCollection();
  2316.         $locations->add($this->getLocation());
  2317.         foreach ($this->getLocations() as $location) {
  2318.             if (!$locations->contains($location)) {
  2319.                 $locations->add($location);
  2320.             }
  2321.         }
  2322.         return $locations;
  2323.     }
  2324.     /**
  2325.      * @return array
  2326.      */
  2327.     public function getAllLocationsIDs()
  2328.     {
  2329.         $locations = new ArrayCollection();
  2330.         $locations->add($this->getLocation()->getId());
  2331.         foreach ($this->getLocations() as $location) {
  2332.             if (!$locations->contains($location->getId())) {
  2333.                 $locations->add($location->getId());
  2334.             }
  2335.         }
  2336.         return $locations->toArray();
  2337.     }
  2338.     /**
  2339.      * Add attribute.
  2340.      *
  2341.      * @return Listing
  2342.      */
  2343.     public function addAttribute(ListingAttribute $attribute)
  2344.     {
  2345.         if (!$attribute->isValid()) {
  2346.             return $this;
  2347.         }
  2348.         $attribute->setListing($this);
  2349.         $this->attributes[] = $attribute;
  2350.         return $this;
  2351.     }
  2352.     /**
  2353.      * Set attributes.
  2354.      *
  2355.      * @return Listing
  2356.      */
  2357.     public function setAttributes($attributes)
  2358.     {
  2359.         foreach ($attributes as $attribute) {
  2360.             if (
  2361.                 $attribute instanceof ListingAttribute
  2362.                 && !$attribute->isValid()
  2363.             ) {
  2364.                 continue;
  2365.             }
  2366.             $this->addAttribute($attribute);
  2367.         }
  2368.         return $this;
  2369.     }
  2370.     /**
  2371.      * Remove attribute.
  2372.      */
  2373.     public function removeAttribute(ListingAttribute $attribute): void
  2374.     {
  2375.         $this->attributes->removeElement($attribute);
  2376.     }
  2377.     /**
  2378.      * Clear attributes.
  2379.      */
  2380.     public function clearAttributes(): void
  2381.     {
  2382.         $this->attributes->clear();
  2383.     }
  2384.     /**
  2385.      * Get attributes.
  2386.      *
  2387.      * @return Collection
  2388.      */
  2389.     public function getAttributes()
  2390.     {
  2391.         return $this->attributes;
  2392.     }
  2393.     /**
  2394.      * Get Attributes in List.
  2395.      *
  2396.      * @return array
  2397.      */
  2398.     public function getAttributesList()
  2399.     {
  2400.         $attributeList = [];
  2401.         foreach ($this->attributes as $attribute) {
  2402.             $value $attribute->getValue();
  2403.             if (
  2404.                 PluralCustomFields::MAX_VALUE == $value
  2405.                 && \in_array($attribute->getCustomField()->getName(), PluralCustomFields::getChoices())
  2406.             ) {
  2407.                 $value PluralCustomFields::MAX_VALUE_LABEL;
  2408.             }
  2409.             $attributeList[$attribute->getCustomField()->getName()] = $value;
  2410.             if (ListingCustomFields::FINISH_TYPE_NAME == $attribute->getCustomField()->getName()) {
  2411.                 $attributeList[$attribute->getCustomField()->getName()] = $attribute->getValue();
  2412.             }
  2413.         }
  2414.         return $attributeList;
  2415.     }
  2416.     /**
  2417.      * Get attributes.
  2418.      *
  2419.      * @return Collection
  2420.      */
  2421.     public function getAttribute($attrName)
  2422.     {
  2423.         foreach ($this->attributes as $attribute) {
  2424.             if ($attrName == $attribute->getCustomField()->getName()) {
  2425.                 return $attribute;
  2426.             }
  2427.         }
  2428.     }
  2429.     /**
  2430.      * Add phones.
  2431.      *
  2432.      * @param ListingPhone $phone
  2433.      *
  2434.      * @return Listing
  2435.      */
  2436.     public function addPhone($phone)
  2437.     {
  2438.         $phone->setListing($this); // Synchronously updating inverse side
  2439.         $criteria Criteria::create()->where(Criteria::expr()->eq('number'$phone->getNumber()));
  2440.         if ($this->getPhones()->matching($criteria)->isEmpty()) {
  2441.             $this->phones[] = $phone;
  2442.         }
  2443.         return $this;
  2444.     }
  2445.     /**
  2446.      * Set Phones.
  2447.      *
  2448.      * @return Listing
  2449.      */
  2450.     public function setPhones($phones)
  2451.     {
  2452.         foreach ($phones as $phone) {
  2453.             $this->addPhone($phone);
  2454.         }
  2455.         return $this;
  2456.     }
  2457.     /**
  2458.      * Remove phone.
  2459.      */
  2460.     public function removePhone(ListingPhone $phone): void
  2461.     {
  2462.         $phone->setListing(null);
  2463.         $this->phones->removeElement($phone);
  2464.     }
  2465.     public function removePhones(): void
  2466.     {
  2467.         foreach ($this->phones as $phone) {
  2468.             $this->removePhone($phone);
  2469.         }
  2470.     }
  2471.     /**
  2472.      * Get phones.
  2473.      *
  2474.      * @Serializer\Groups({"List", "Details", "RelatedListingsV2", "listingDetails"})
  2475.      *
  2476.      * @Serializer\VirtualProperty
  2477.      *
  2478.      * @Serializer\Expose
  2479.      *
  2480.      * @return ArrayCollection
  2481.      */
  2482.     public function getPhones()
  2483.     {
  2484.         return $this->listMainListingPhonesFromUser();
  2485.     }
  2486.     /**
  2487.      * Get Mapped Phones For V4.
  2488.      *
  2489.      * @Serializer\Groups({"DefaultV4", "SearchV4", "ProjectDetailsV4", "ProjectSearchV4","locationListingV2"})
  2490.      *
  2491.      * @Serializer\VirtualProperty
  2492.      *
  2493.      * @Serializer\SerializedName("phones")
  2494.      *
  2495.      * @Serializer\Expose
  2496.      *
  2497.      * @return array
  2498.      */
  2499.     public function getMappedPhones()
  2500.     {
  2501.         $phones = [];
  2502.         /** @var $phone ListingPhone */
  2503.         foreach ($this->getPhones() as $phone) {
  2504.             $phones[] = $phone->getPhone();
  2505.         }
  2506.         return $phones;
  2507.     }
  2508.     /**
  2509.      * Get phones for listing from the user phones.
  2510.      *
  2511.      * @Serializer\Groups({"List", "Details", "listingDetails", "SearchV4", "NewLeadGeneration"})
  2512.      *
  2513.      * @Serializer\VirtualProperty
  2514.      *
  2515.      * @Serializer\Expose
  2516.      */
  2517.     public function getListingPhones(): ArrayCollection
  2518.     {
  2519.         $phones = new ArrayCollection();
  2520.         $i 0;
  2521.         /** @var UserPhone $phone */
  2522.         foreach ($this->getUser()->getPhones() as $phone) {
  2523.             if ($i 2) {
  2524.                 break;
  2525.             }
  2526.             $criteria Criteria::create()->where(Criteria::expr()->eq('number'$phone->getNumber()));
  2527.             if ($phones->matching($criteria)->isEmpty() && $phone->getPhone() instanceof Phone) {
  2528.                 $phones->add($phone->getPhone());
  2529.             }
  2530.             ++$i;
  2531.         }
  2532.         return $phones;
  2533.     }
  2534.     /**
  2535.      * Add photos.
  2536.      *
  2537.      * @return Listing
  2538.      */
  2539.     public function addPhoto(ListingPhoto $photo)
  2540.     {
  2541.         $photo->setListing($this);
  2542.         $this->photos->add($photo);
  2543.         return $this;
  2544.     }
  2545.     /**
  2546.      * Set photos.
  2547.      *
  2548.      * @return Listing
  2549.      */
  2550.     public function setPhotos($photos)
  2551.     {
  2552.         foreach ($photos as $photo) {
  2553.             $this->addPhoto($photo);
  2554.         }
  2555.         return $this;
  2556.     }
  2557.     /**
  2558.      * Remove photos.
  2559.      */
  2560.     public function removePhoto(ListingPhoto $photo): void
  2561.     {
  2562.         $this->photos->removeElement($photo);
  2563.     }
  2564.     /**
  2565.      * @return $this
  2566.      */
  2567.     public function clearPhotos()
  2568.     {
  2569.         $this->photos->clear();
  2570.         return $this;
  2571.     }
  2572.     /**
  2573.      * @return $this
  2574.      */
  2575.     public function clearPhones()
  2576.     {
  2577.         $this->phones->clear();
  2578.         return $this;
  2579.     }
  2580.     /**
  2581.      * @return CompoundAveragePrice|null
  2582.      */
  2583.     public function getCompoundAveragePrices()
  2584.     {
  2585.         return $this->compoundAveragePrices;
  2586.     }
  2587.     /**
  2588.      * @param CompoundAveragePrice|null
  2589.      */
  2590.     public function setCompoundAveragePrices(?CompoundAveragePrice $compoundAveragePrices): void
  2591.     {
  2592.         $this->compoundAveragePrices $compoundAveragePrices;
  2593.     }
  2594.     /**
  2595.      * @return ArrayCollection
  2596.      */
  2597.     public function getPhotos($excludedTypes = [])
  2598.     {
  2599.         $criteria Criteria::create();
  2600.         if (!empty($excludedTypes)) {
  2601.             $criteria->andWhere(Criteria::expr()->notIn('type'$excludedTypes));
  2602.         }
  2603.         $criteria->orderBy(['order' => Criteria::ASC]);
  2604.         return $this->photos->matching($criteria);
  2605.     }
  2606.     /**
  2607.      * @Serializer\Groups({"List", "Details", "listingDetails"})
  2608.      *
  2609.      * @Serializer\VirtualProperty
  2610.      *
  2611.      * @Serializer\SerializedName("photos")
  2612.      *
  2613.      * @return ArrayCollection
  2614.      */
  2615.     public function getPhotosForSlider()
  2616.     {
  2617.         $slider = new ArrayCollection();
  2618.         // Set the main photo as the first photo in the slider
  2619.         if ($this->getMainPhoto()) {
  2620.             $slider->add($this->getMainPhoto());
  2621.         }
  2622.         // Add all other photos, except the main photo, because It's already added
  2623.         /** @var ListingPhoto $photo */
  2624.         foreach ($this->getPhotos() as $photo) {
  2625.             if (!$slider->contains($photo) && PhotoTypes::LOGO_PHOTO != $photo->getType()) {
  2626.                 $slider->add($photo);
  2627.             }
  2628.         }
  2629.         return $slider;
  2630.     }
  2631.     public function buildMappedMainPhoto(): self
  2632.     {
  2633.         // Important for API
  2634.         if ($this->getPhotos()->count() <= 0) {
  2635.             return $this;
  2636.         }
  2637.         /* @var ListingPhoto $photo */
  2638.         $mainPhotos $this->photos->filter(fn ($photo) => PhotoTypes::MAIN_PHOTO == $photo->getType());
  2639.         $mappedMainPhoto $mainPhotos->first() ?: $this->getPhotos()->first();
  2640.         if ($mappedMainPhoto instanceof ListingPhoto) {
  2641.             $this->mappedMainPhoto $this->mapPhoto($mappedMainPhoto);
  2642.         }
  2643.         return $this;
  2644.     }
  2645.     public function setMappedMainPhoto(?array $mainPhoto): self
  2646.     {
  2647.         $this->mappedMainPhoto $mainPhoto;
  2648.         return $this;
  2649.     }
  2650.     /**
  2651.      * @Serializer\Groups({"DefaultV4", "MyListing", "MyListings", "SearchV4", "ProjectSearchV4", "RelatedListingsV2", "locationListingV2", "homeCompoundV2"})
  2652.      *
  2653.      * @Serializer\VirtualProperty
  2654.      *
  2655.      * @Serializer\SerializedName("mainPhoto")
  2656.      */
  2657.     public function getMappedMainPhoto(): ?array
  2658.     {
  2659.         return $this->mappedMainPhoto;
  2660.     }
  2661.     private function mapPhoto(ListingPhoto $listingPhoto): array
  2662.     {
  2663.         return [
  2664.             'id' => $listingPhoto->getId(),
  2665.             'name' => $listingPhoto->getName(),
  2666.             'caption' => $listingPhoto->getCaption(),
  2667.             'order' => $listingPhoto->getOrder(),
  2668.             'type' => $listingPhoto->getTypeName(),
  2669.             'photo' => $listingPhoto->getFile(),
  2670.             'file' => $listingPhoto->getPath(),
  2671.             'thumbnails' => [],
  2672.         ];
  2673.     }
  2674.     public function buildMappedPhotos(): self
  2675.     {
  2676.         $mainPhotoId null;
  2677.         // Set the main photo as the first photo in the slider
  2678.         if ($this->getMainPhoto() instanceof ListingPhoto) {
  2679.             $mainPhoto $this->getMainPhoto();
  2680.             $mainPhotoId $mainPhoto->getId();
  2681.             $this->mappedPhotos[] = $this->mapPhoto($mainPhoto);
  2682.         }
  2683.         /** @var ListingPhoto $photo */
  2684.         foreach ($this->getPhotos() as $photo) {
  2685.             if (PhotoTypes::LOGO_PHOTO != $photo->getType()) {
  2686.                 if (($mainPhotoId && $mainPhotoId == $photo->getId()) || !$photo instanceof ListingPhoto) {
  2687.                     continue;
  2688.                 }
  2689.                 $this->mappedPhotos[] = $this->mapPhoto($photo);
  2690.             }
  2691.         }
  2692.         return $this;
  2693.     }
  2694.     /**
  2695.      * @Serializer\Groups({"DefaultV4", "SearchV4", "ProjectDetailsV4", "RelatedListingsV2"})
  2696.      *
  2697.      * @Serializer\VirtualProperty
  2698.      *
  2699.      * @Serializer\SerializedName("photos")
  2700.      *
  2701.      * @return array
  2702.      */
  2703.     public function getMappedPhotos()
  2704.     {
  2705.         return $this->mappedPhotos;
  2706.     }
  2707.     public function setMappedPhotos(array $mappedPhotos): self
  2708.     {
  2709.         $this->mappedPhotos $mappedPhotos;
  2710.         return $this;
  2711.     }
  2712.     /**
  2713.      * @Serializer\Groups({"List", "Api", "Preview"})
  2714.      *
  2715.      * @Serializer\VirtualProperty
  2716.      */
  2717.     public function getMainPhoto(): ?ListingPhoto
  2718.     {
  2719.         // Important for API
  2720.         if ($this->getPhotos()->count() <= 0) {
  2721.             return null;
  2722.         }
  2723.         /* @var ListingPhoto $photo */
  2724.         $mainPhotos $this->photos->filter(fn ($photo) => PhotoTypes::MAIN_PHOTO == $photo->getType());
  2725.         return $mainPhotos->first() ?: $this->getPhotos()->first();
  2726.     }
  2727.     /**
  2728.      * @Serializer\Groups({"DefaultV4", "MyListing", "SearchV4", "ProjectSearchV4"})
  2729.      *
  2730.      * @Serializer\VirtualProperty
  2731.      *
  2732.      * @return int
  2733.      */
  2734.     public function getPhotosCount()
  2735.     {
  2736.         return $this->getPhotos()->count();
  2737.     }
  2738.     /**
  2739.      * @return ListingPhoto|null
  2740.      */
  2741.     public function getLogo()
  2742.     {
  2743.         /** @var ArrayCollection $logos */
  2744.         $logos $this->photos->filter(fn (ListingPhoto $photo) => PhotoTypes::LOGO_PHOTO == $photo->getType());
  2745.         return $logos->first() ?: null;
  2746.     }
  2747.     /**
  2748.      * @return ArrayCollection
  2749.      */
  2750.     public function getLeads()
  2751.     {
  2752.         return $this->leads;
  2753.     }
  2754.     /**
  2755.      * Count leads.
  2756.      *
  2757.      * @return int
  2758.      */
  2759.     public function getLeadsCount()
  2760.     {
  2761.         return $this->getLeadsCounter();
  2762.     }
  2763.     /**
  2764.      * Count all leads with children.
  2765.      *
  2766.      * @return int
  2767.      */
  2768.     public function getTotalLeadsCount()
  2769.     {
  2770.         $leadsCount $this->getLeadsCounter();
  2771.         if ($this->getChildren()) {
  2772.             /** @var self $listing */
  2773.             foreach ($this->getChildren() as $listing) {
  2774.                 $leadsCount += $listing->getLeadsCounter();
  2775.             }
  2776.         }
  2777.         return $leadsCount;
  2778.     }
  2779.     public function setLeads($leads): void
  2780.     {
  2781.         $this->leads $leads;
  2782.     }
  2783.     /**
  2784.      * @Serializer\VirtualProperty()
  2785.      *
  2786.      * @return int
  2787.      */
  2788.     public function getAggregatedLeadsCount()
  2789.     {
  2790.         /** @var ListingFeature $lastBump */
  2791.         $lastBump $this->getLastAutoBumpUp();
  2792.         /** @var ListingFeature $lastFeature */
  2793.         $lastFeature $this->getLastListingFeature();
  2794.         $listingFeature null;
  2795.         if ($lastBump && $lastFeature) {
  2796.             $listingFeature = ($lastBump->getLastBumpedAt() > $lastFeature->getCreatedAt()) ? $lastBump $lastFeature;
  2797.         } elseif ($lastBump) {
  2798.             $listingFeature $lastBump;
  2799.         } elseif ($lastFeature) {
  2800.             $listingFeature $lastFeature;
  2801.         }
  2802.         return $listingFeature ?
  2803.             $this->getLeadsCounter() - $listingFeature->getLeadsCountSnapshot() :
  2804.             $this->getLeadsCounter();
  2805.     }
  2806.     /**
  2807.      * Add listingFeatures.
  2808.      *
  2809.      * @return Listing
  2810.      */
  2811.     public function addListingFeature(ListingFeature $listingFeatures)
  2812.     {
  2813.         $this->listingFeatures[] = $listingFeatures;
  2814.         return $this;
  2815.     }
  2816.     /**
  2817.      * Remove listingFeatures.
  2818.      */
  2819.     public function removeListingFeature(ListingFeature $listingFeatures): void
  2820.     {
  2821.         $this->listingFeatures->removeElement($listingFeatures);
  2822.     }
  2823.     /**
  2824.      * Get listingFeatures.
  2825.      *
  2826.      * @return Collection
  2827.      */
  2828.     public function getListingFeatures()
  2829.     {
  2830.         return $this->listingFeatures;
  2831.     }
  2832.     /**
  2833.      * @return ListingFeature
  2834.      */
  2835.     public function getLastAutoBumpUp()
  2836.     {
  2837.         $criteria = new Criteria();
  2838.         $criteria
  2839.             ->where(Criteria::expr()->eq('type'ListingFeatures::BUMP_UP))
  2840.             ->andWhere(Criteria::expr()->gte('expiresAt', new \DateTime()))
  2841.             ->orWhere(Criteria::expr()->isNull('expiresAt'))
  2842.             ->orderBy([
  2843.                 'id' => Criteria::DESC,
  2844.             ])
  2845.         ;
  2846.         return $this->listingFeatures->matching($criteria)->first();
  2847.     }
  2848.     /**
  2849.      * @Serializer\VirtualProperty
  2850.      *
  2851.      * @Serializer\SerializedName("was_featured")
  2852.      *
  2853.      * @Serializer\Groups({"List", "Details", "listingDetails"})
  2854.      *
  2855.      * @return bool
  2856.      */
  2857.     public function wasFeatured()
  2858.     {
  2859.         return !$this->getCurrentListingFeature() && $this->getLastListingFeature() ? true false;
  2860.     }
  2861.     /**
  2862.      * Get current listing feature.
  2863.      *
  2864.      * @return ListingFeatures
  2865.      */
  2866.     public function getCurrentListingFeature()
  2867.     {
  2868.         $criteria Criteria::create()
  2869.             ->where(Criteria::expr()->gte('expiresAt', new \DateTime('now')))
  2870.             ->andWhere(Criteria::expr()->neq('type'ListingFeatures::PAID))
  2871.             ->andWhere(Criteria::expr()->neq('type'ListingFeatures::BUMP_UP))
  2872.             ->orderBy(['id' => Criteria::DESC])
  2873.             ->setMaxResults(1);
  2874.         return $this->getListingFeatures()->matching($criteria)->first();
  2875.     }
  2876.     /**
  2877.      * Get current listing feature expiry date.
  2878.      *
  2879.      * @return \DateTime|null
  2880.      *
  2881.      * @Serializer\VirtualProperty()
  2882.      *
  2883.      * @Serializer\Groups({"DefaultV4", "MyListing"})
  2884.      *
  2885.      * @Serializer\SerializedName("feature_expires_at")
  2886.      *
  2887.      * @Serializer\Expose
  2888.      */
  2889.     public function getCurrentListingFeatureExpiryDate()
  2890.     {
  2891.         /* @var ListingFeature $listingFeature */
  2892.         if ($this->isFeatured()) {
  2893.             $listingFeature $this->getCurrentListingFeature();
  2894.             return $listingFeature $listingFeature->getExpiresAt() : null;
  2895.         }
  2896.         return null;
  2897.     }
  2898.     /**
  2899.      * Get all current active listing features.
  2900.      *
  2901.      * @return ListingFeatures
  2902.      */
  2903.     public function getCurrentListingFeatures()
  2904.     {
  2905.         $criteria Criteria::create()
  2906.             ->where(Criteria::expr()->orX(
  2907.                 Criteria::expr()->isNull('expiresAt'),
  2908.                 Criteria::expr()->gte('expiresAt', new \DateTime('now'))
  2909.             ))
  2910.             ->orderBy(['id' => Criteria::DESC]);
  2911.         return $this->getListingFeatures()->matching($criteria);
  2912.     }
  2913.     /**
  2914.      * Get last listing feature.
  2915.      */
  2916.     public function getLastListingFeature()
  2917.     {
  2918.         $criteria Criteria::create()
  2919.             ->andWhere(Criteria::expr()->neq('type'ListingFeatures::PAID))
  2920.             ->andWhere(Criteria::expr()->neq('type'ListingFeatures::BUMP_UP))
  2921.             ->orderBy(['id' => Criteria::DESC])
  2922.             ->setMaxResults(1);
  2923.         return $this->getListingFeatures()->matching($criteria)->first();
  2924.     }
  2925.     /**
  2926.      * Get the latest  featured credit transaction for listing publishing.
  2927.      *
  2928.      * @param mixed $type = null
  2929.      *
  2930.      * @throws \Exception
  2931.      */
  2932.     public function getFeaturedPublicationCredit($type null)
  2933.     {
  2934.         if (!$type) {
  2935.             $lastFeaturedType $this->getLastListingFeature() ? $this->getLastListingFeature()->getType() : [];
  2936.             $type = !empty($lastFeaturedType) ? [$lastFeaturedType] : [ListingFeatures::FEATUREDListingFeatures::SPOTLIGHTListingFeatures::PREMIUMListingFeatures::SPONSORED];
  2937.         }
  2938.         $criteria Criteria::create()
  2939.             ->where(Criteria::expr()->orX(
  2940.                 Criteria::expr()->isNull('expiresAt'),
  2941.                 Criteria::expr()->gte('expiresAt', new \DateTime('now'))
  2942.             ))
  2943.             ->andWhere(Criteria::expr()->in('type'$type))
  2944.             ->orderBy(['id' => Criteria::DESC])
  2945.             ->setMaxResults(1);
  2946.         return $this->getListingFeatures()->matching($criteria)->first();
  2947.     }
  2948.     /**
  2949.      * Get the latest credit transaction for listing publishing.
  2950.      *
  2951.      * @return ListingFeature
  2952.      */
  2953.     public function getPublicationCredit()
  2954.     {
  2955.         $criteria Criteria::create()
  2956.             ->where(Criteria::expr()->orX(
  2957.                 Criteria::expr()->isNull('expiresAt'),
  2958.                 Criteria::expr()->gte('expiresAt', new \DateTime('now'))
  2959.             ))
  2960.             ->andWhere(Criteria::expr()->eq('type'ListingFeatures::PAID))
  2961.             ->orderBy(['id' => Criteria::DESC])
  2962.             ->setMaxResults(1);
  2963.         return $this->getListingFeatures()->matching($criteria)->first();
  2964.     }
  2965.     /**
  2966.      * Get the latest credit transaction for special add listing publishing.
  2967.      *
  2968.      * @return ListingFeature
  2969.      */
  2970.     public function getSpecialPublicationCredit()
  2971.     {
  2972.         $criteria Criteria::create()
  2973.             ->where(Criteria::expr()->orX(
  2974.                 Criteria::expr()->isNull('expiresAt'),
  2975.                 Criteria::expr()->gte('expiresAt', new \DateTime('now'))
  2976.             ))
  2977.             ->andWhere(Criteria::expr()->in('type', [ListingFeatures::SPONSOREDListingFeatures::SPOTLIGHT]))
  2978.             ->orderBy(['id' => Criteria::DESC])
  2979.             ->setMaxResults(1);
  2980.         return $this->getListingFeatures()->matching($criteria)->first();
  2981.     }
  2982.     /**
  2983.      * Get all credit transactions for listing that not expired yet.
  2984.      *
  2985.      * @return ListingFeature
  2986.      */
  2987.     public function getNotExpiredCredit()
  2988.     {
  2989.         $criteria Criteria::create()
  2990.             ->where(Criteria::expr()->orX(
  2991.                 Criteria::expr()->isNull('expiresAt'),
  2992.                 Criteria::expr()->gte('expiresAt', new \DateTime('now'))
  2993.             ))
  2994.             ->orderBy(['id' => Criteria::DESC]);
  2995.         return $this->getListingFeatures()->matching($criteria)->toArray();
  2996.     }
  2997.     /**
  2998.      * Get translations.
  2999.      *
  3000.      * @Serializer\VirtualProperty
  3001.      *
  3002.      * @Serializer\Groups({"Default", "List"})
  3003.      *
  3004.      * @Serializer\SerializedName("translations")
  3005.      *
  3006.      * @Serializer\Expose
  3007.      *
  3008.      * @return ArrayCollection
  3009.      */
  3010.     public function getTranslations()
  3011.     {
  3012.         return $this->translations;
  3013.     }
  3014.     public function deleteExistingTranslation($field$locale): void
  3015.     {
  3016.         /** @var ListingTranslation $translation */
  3017.         foreach ($this->getTranslations() as $translation) {
  3018.             if ($translation->getField() == $field && $translation->getLocale() == $locale) {
  3019.                 $this->removeTranslation($translation);
  3020.             }
  3021.         }
  3022.     }
  3023.     /**
  3024.      * Add translation.
  3025.      *
  3026.      * @return Listing
  3027.      */
  3028.     public function addTranslation(ListingTranslation $translation)
  3029.     {
  3030.         if (!$this->translations->contains($translation)) {
  3031.             $this->translations->add($translation);
  3032.             $translation->setObject($this);
  3033.         }
  3034.         return $this;
  3035.     }
  3036.     /**
  3037.      * Set Translations.
  3038.      *
  3039.      * @return Listing
  3040.      */
  3041.     public function setTranslations($translations)
  3042.     {
  3043.         foreach ($translations as $translation) {
  3044.             $this->addTranslation($translation);
  3045.         }
  3046.         return $this;
  3047.     }
  3048.     /**
  3049.      * Remove translation.
  3050.      *
  3051.      * @return Listing
  3052.      */
  3053.     public function removeTranslation(ListingTranslation $translation)
  3054.     {
  3055.         if ($this->translations->contains($translation)) {
  3056.             $this->translations->removeElement($translation);
  3057.         }
  3058.         return $this;
  3059.     }
  3060.     /**
  3061.      * @return $this
  3062.      */
  3063.     public function clearTranslations()
  3064.     {
  3065.         $this->translations->clear();
  3066.         return $this;
  3067.     }
  3068.     /**
  3069.      * Set campaign.
  3070.      *
  3071.      * @param string $campaign
  3072.      *
  3073.      * @return Listing
  3074.      */
  3075.     public function setCampaign($campaign)
  3076.     {
  3077.         $this->campaign $campaign;
  3078.         return $this;
  3079.     }
  3080.     /**
  3081.      * Get campaign.
  3082.      *
  3083.      * @return string
  3084.      */
  3085.     public function getCampaign()
  3086.     {
  3087.         return $this->campaign;
  3088.     }
  3089.     /**
  3090.      * Set propertyView.
  3091.      *
  3092.      * @param int $propertyView
  3093.      *
  3094.      * @return Listing
  3095.      */
  3096.     public function setPropertyView($propertyView)
  3097.     {
  3098.         $this->propertyView $propertyView;
  3099.         return $this;
  3100.     }
  3101.     /**
  3102.      * Get propertyView.
  3103.      *
  3104.      * @return int
  3105.      */
  3106.     public function getPropertyView()
  3107.     {
  3108.         return $this->propertyView;
  3109.     }
  3110.     /**
  3111.      * @Serializer\SerializedName("property_view_label")
  3112.      *
  3113.      * @Serializer\VirtualProperty()
  3114.      *
  3115.      * @Serializer\Groups({"Details", "listingDetails"})
  3116.      *
  3117.      * @Serializer\Expose
  3118.      */
  3119.     public function getPropertyViewLabel()
  3120.     {
  3121.         return ListingPropertyView::getLabel($this->getPropertyView());
  3122.     }
  3123.     /**
  3124.      * @Serializer\SerializedName("property_view_label")
  3125.      *
  3126.      * @Serializer\VirtualProperty()
  3127.      *
  3128.      * @Serializer\Since("v2.12")
  3129.      *
  3130.      * @Serializer\Expose()
  3131.      */
  3132.     public function getPropertyViewTranslatedLabel()
  3133.     {
  3134.         return $this->getTranslatedPropertyViewLabel();
  3135.     }
  3136.     /**
  3137.      * @Serializer\SerializedName("property_view")
  3138.      *
  3139.      * @Serializer\VirtualProperty()
  3140.      *
  3141.      * @Serializer\Groups({"DefaultV4"})
  3142.      *
  3143.      * @Serializer\Expose()
  3144.      */
  3145.     public function getPropertyViewName()
  3146.     {
  3147.         return ListingPropertyView::getNameByConstant($this->getPropertyView());
  3148.     }
  3149.     /**
  3150.      * @return $this
  3151.      */
  3152.     public function setPropertyViewLabel($label)
  3153.     {
  3154.         $this->propertyViewLabel $label;
  3155.         return $this;
  3156.     }
  3157.     /**
  3158.      * Set paymentMethod.
  3159.      *
  3160.      * @param int $paymentMethod
  3161.      *
  3162.      * @return Listing
  3163.      */
  3164.     public function setPaymentMethod($paymentMethod)
  3165.     {
  3166.         if (
  3167.             ListingSections::FOR_RENT == $this->getSection()->getId()
  3168.         ) {
  3169.             $paymentMethod ListingPaymentMethod::CASH;
  3170.         }
  3171.         $this->paymentMethod $paymentMethod;
  3172.         return $this;
  3173.     }
  3174.     /**
  3175.      * Set paymentMethod Label.
  3176.      *
  3177.      * @param int $paymentMethod
  3178.      *
  3179.      * @return Listing
  3180.      */
  3181.     public function setPaymentMethodLabel($paymentMethod)
  3182.     {
  3183.         $this->paymentMethodLabel $paymentMethod;
  3184.         return $this;
  3185.     }
  3186.     /**
  3187.      * @Serializer\SerializedName("payment_method_label")
  3188.      *
  3189.      * @Serializer\VirtualProperty()
  3190.      *
  3191.      * @Serializer\Since("v2.12")
  3192.      *
  3193.      * @Serializer\Expose()
  3194.      */
  3195.     public function getPaymentMethodLabelTranslated()
  3196.     {
  3197.         return $this->paymentMethodLabel;
  3198.     }
  3199.     /**
  3200.      * @Serializer\SerializedName("user")
  3201.      *
  3202.      * @Serializer\VirtualProperty()
  3203.      *
  3204.      * @Serializer\Groups({"DefaultV4"})
  3205.      *
  3206.      * @Serializer\Expose()
  3207.      *
  3208.      * @return int|null
  3209.      */
  3210.     public function getUserId()
  3211.     {
  3212.         return $this->getUser() instanceof User $this->getUser()->getId() : null;
  3213.     }
  3214.     /**
  3215.      * Get paymentMethod.
  3216.      *
  3217.      * @return int
  3218.      */
  3219.     public function getPaymentMethod()
  3220.     {
  3221.         if (
  3222.             ListingSections::FOR_RENT == $this->getSection()->getId()
  3223.         ) {
  3224.             $this->paymentMethod ListingPaymentMethod::CASH;
  3225.         }
  3226.         return $this->paymentMethod;
  3227.     }
  3228.     /**
  3229.      * @Serializer\SerializedName("paymentMethodLabel")
  3230.      *
  3231.      * @Serializer\VirtualProperty()
  3232.      *
  3233.      * @Serializer\Groups({"Default", "SearchV4", "listingDetails"})
  3234.      *
  3235.      * @Serializer\Expose()
  3236.      */
  3237.     public function getPaymentMethodLabel()
  3238.     {
  3239.         return ListingPaymentMethod::getLabel($this->getPaymentMethod());
  3240.     }
  3241.     /**
  3242.      * Add listingNotification.
  3243.      *
  3244.      * @return Listing
  3245.      */
  3246.     public function addListingNotification(ListingNotification $listingNotification)
  3247.     {
  3248.         $this->ListingNotifications[] = $listingNotification;
  3249.         return $this;
  3250.     }
  3251.     /**
  3252.      * Remove listingNotification.
  3253.      */
  3254.     public function removeListingNotification(ListingNotification $listingNotification): void
  3255.     {
  3256.         $this->ListingNotifications->removeElement($listingNotification);
  3257.     }
  3258.     /**
  3259.      * Get listingNotifications.
  3260.      *
  3261.      * @return Collection
  3262.      */
  3263.     public function getListingNotifications()
  3264.     {
  3265.         return $this->ListingNotifications;
  3266.     }
  3267.     /**
  3268.      * Add rejections.
  3269.      *
  3270.      * @return Listing
  3271.      */
  3272.     public function addRejection(Rejection $rejections)
  3273.     {
  3274.         $this->rejections[] = $rejections;
  3275.         return $this;
  3276.     }
  3277.     /**
  3278.      * Add rejections.
  3279.      *
  3280.      * @param ArrayCollection $rejections
  3281.      *
  3282.      * @return Listing
  3283.      */
  3284.     public function addRejections($rejections)
  3285.     {
  3286.         $this->rejections $rejections;
  3287.         return $this;
  3288.     }
  3289.     /**
  3290.      * Remove rejections.
  3291.      */
  3292.     public function removeRejections(Rejection $rejections): void
  3293.     {
  3294.         $this->rejections->removeElement($rejections);
  3295.     }
  3296.     /**
  3297.      * Get rejections.
  3298.      *
  3299.      * @return Collection
  3300.      */
  3301.     public function getRejections()
  3302.     {
  3303.         return $this->rejections;
  3304.     }
  3305.     public function setRejections($rejections): void
  3306.     {
  3307.         $this->rejections $rejections;
  3308.     }
  3309.     /**
  3310.      * Set phoneCounter.
  3311.      *
  3312.      * @param int $phoneCounter
  3313.      *
  3314.      * @return Listing
  3315.      */
  3316.     public function setPhoneCounter($phoneCounter)
  3317.     {
  3318.         $this->phoneCounter $phoneCounter;
  3319.         return $this;
  3320.     }
  3321.     /**
  3322.      * Get phoneCounter.
  3323.      *
  3324.      * @return int
  3325.      */
  3326.     public function getPhoneCounter()
  3327.     {
  3328.         return $this->phoneCounter;
  3329.     }
  3330.     /**
  3331.      * Set messagesCounter.
  3332.      *
  3333.      * @param int $messagesCounter
  3334.      *
  3335.      * @return Listing
  3336.      */
  3337.     public function setMessagesCounter($messagesCounter)
  3338.     {
  3339.         $this->messagesCounter $messagesCounter;
  3340.         return $this;
  3341.     }
  3342.     /**
  3343.      * Get messagesCounter.
  3344.      *
  3345.      * @return int
  3346.      */
  3347.     public function getMessagesCounter()
  3348.     {
  3349.         return $this->messagesCounter;
  3350.     }
  3351.     /**
  3352.      * @return int
  3353.      */
  3354.     public function getFinalPrice()
  3355.     {
  3356.         return $this->finalPrice;
  3357.     }
  3358.     /**
  3359.      * @param int $finalPrice
  3360.      */
  3361.     public function setFinalPrice($finalPrice): void
  3362.     {
  3363.         $this->finalPrice $finalPrice;
  3364.     }
  3365.     /**
  3366.      * @return string
  3367.      */
  3368.     public function getSourceOfSale()
  3369.     {
  3370.         return $this->sourceOfSale;
  3371.     }
  3372.     /**
  3373.      * @param string $sourceOfSale
  3374.      */
  3375.     public function setSourceOfSale($sourceOfSale): void
  3376.     {
  3377.         $this->sourceOfSale $sourceOfSale;
  3378.     }
  3379.     /**
  3380.      * @return string
  3381.      */
  3382.     public function getDeleteReason()
  3383.     {
  3384.         return $this->deleteReason;
  3385.     }
  3386.     /**
  3387.      * @param string $deleteReason
  3388.      */
  3389.     public function setDeleteReason($deleteReason): void
  3390.     {
  3391.         $this->deleteReason $deleteReason;
  3392.     }
  3393.     /**
  3394.      * @return string
  3395.      */
  3396.     public function getDeleteReasonDetails()
  3397.     {
  3398.         return $this->deleteReasonDetails;
  3399.     }
  3400.     /**
  3401.      * @param string $deleteReasonDetails
  3402.      */
  3403.     public function setDeleteReasonDetails($deleteReasonDetails): void
  3404.     {
  3405.         $this->deleteReasonDetails $deleteReasonDetails;
  3406.     }
  3407.     public function getInteractions()
  3408.     {
  3409.         return $this->interactions;
  3410.     }
  3411.     public function setInteractions($interactions): void
  3412.     {
  3413.         $this->interactions $interactions;
  3414.     }
  3415.     /**
  3416.      * @Serializer\VirtualProperty
  3417.      *
  3418.      * @Serializer\SerializedName("logo")
  3419.      *
  3420.      * @Serializer\Groups({"ProjectSearchV4", "ProjectDetailsV4", "locationListingV2"})
  3421.      */
  3422.     public function getSerializedLogo()
  3423.     {
  3424.         // Giving priority for listing logo then userLogo. value set on ListingPreSerializerListener.
  3425.         return $this->getListingLogo() ?: ($this->getUserLogo() ?: null);
  3426.     }
  3427.     /**
  3428.      * @return string
  3429.      */
  3430.     public function getUserLogo()
  3431.     {
  3432.         return $this->userLogo;
  3433.     }
  3434.     /**
  3435.      * @param string $userLogo
  3436.      */
  3437.     public function setUserLogo($userLogo): void
  3438.     {
  3439.         $this->userLogo $userLogo;
  3440.     }
  3441.     public function getValidUserLogo(): ?Photo
  3442.     {
  3443.         if ($user $this->getUser()) {
  3444.             if ($user->hasValidAccessToLogoExposure()) {
  3445.                 return $user->getLogo();
  3446.             }
  3447.         }
  3448.         return null;
  3449.     }
  3450.     /**
  3451.      * @return string
  3452.      */
  3453.     public function getListingLogo()
  3454.     {
  3455.         return $this->listingLogo;
  3456.     }
  3457.     /**
  3458.      * @param string $listingLogo
  3459.      */
  3460.     public function setListingLogo($listingLogo): void
  3461.     {
  3462.         $this->listingLogo $listingLogo;
  3463.     }
  3464.     public function setTranslatableLocale($locale): void
  3465.     {
  3466.         $this->locale $locale;
  3467.     }
  3468.     /**
  3469.      * @return bool
  3470.      */
  3471.     public function canChangeScrapedListing()
  3472.     {
  3473.         return ListingCategories::SCRAPPED == $this->category
  3474.             && ScrapedListing::USER_EMAIL === $this->getUser()->getEmail();
  3475.     }
  3476.     /**
  3477.      * @param null $hash
  3478.      *
  3479.      * @return bool
  3480.      */
  3481.     public function validateScrapedListingHash($hash null)
  3482.     {
  3483.         $secretHash md5($this->getPhones()->first()->getNumber().''.$this->getId());
  3484.         if ($hash === $secretHash) {
  3485.             return true;
  3486.         }
  3487.         return false;
  3488.     }
  3489.     public function getSource()
  3490.     {
  3491.         return $this->source;
  3492.     }
  3493.     public function setSource($source): void
  3494.     {
  3495.         $this->source $source;
  3496.     }
  3497.     public function setElasticSearchScore($elasticSearchScore): void
  3498.     {
  3499.         $this->elasticSearchScore $elasticSearchScore;
  3500.     }
  3501.     /**
  3502.      * @return float
  3503.      */
  3504.     public function getElasticSearchScore()
  3505.     {
  3506.         return $this->elasticSearchScore;
  3507.     }
  3508.     /**
  3509.      * @param float $qualityScore
  3510.      */
  3511.     public function setQualityScore($qualityScore): void
  3512.     {
  3513.         $this->qualityScore $qualityScore;
  3514.     }
  3515.     /**
  3516.      * @return float
  3517.      */
  3518.     public function getQualityScore()
  3519.     {
  3520.         return $this->photos->count();
  3521.     }
  3522.     public function getLeadsCounter(): int
  3523.     {
  3524.         return $this->leadsCounter;
  3525.     }
  3526.     /**
  3527.      * @param int $leadsCounter
  3528.      *
  3529.      * @return Listing
  3530.      */
  3531.     public function setLeadsCounter($leadsCounter)
  3532.     {
  3533.         $this->leadsCounter $leadsCounter;
  3534.         return $this;
  3535.     }
  3536.     /**
  3537.      * Get price per meter.
  3538.      *
  3539.      * @return int|null
  3540.      */
  3541.     public function calculatePricePerMeter()
  3542.     {
  3543.         if (!$this->getArea()) {
  3544.             return null;
  3545.         }
  3546.         $area = ($this->getArea() > 0) ? $this->getArea() : 1;
  3547.         return $this->getPrice() / $area;
  3548.     }
  3549.     /**
  3550.      * @return int
  3551.      */
  3552.     public function getImpressions()
  3553.     {
  3554.         return $this->impressions;
  3555.     }
  3556.     /**
  3557.      * @param int $impressions
  3558.      *
  3559.      * @return Listing
  3560.      */
  3561.     public function setImpressions($impressions)
  3562.     {
  3563.         $this->impressions $impressions;
  3564.         return $this;
  3565.     }
  3566.     /**
  3567.      * @return $this
  3568.      */
  3569.     public function setImpressionsMonthlyCount(?int $impressions null)
  3570.     {
  3571.         $this->impressionsMonthlyCount $impressions;
  3572.         return $this;
  3573.     }
  3574.     /**
  3575.      * @return int
  3576.      */
  3577.     public function getImpressionsMonthlyCount()
  3578.     {
  3579.         return $this->impressionsMonthlyCount;
  3580.     }
  3581.     /**
  3582.      * @return $this
  3583.      */
  3584.     public function setImpressionsWeeklyCount(?int $impressions null)
  3585.     {
  3586.         $this->impressionsWeeklyCount $impressions;
  3587.         return $this;
  3588.     }
  3589.     public function getImpressionsWeeklyCount()
  3590.     {
  3591.         return $this->impressionsWeeklyCount;
  3592.     }
  3593.     /**
  3594.      * Get impressionUpdatedAt.
  3595.      *
  3596.      * @return \DateTime
  3597.      */
  3598.     public function getImpressionUpdatedAt()
  3599.     {
  3600.         return $this->impressionUpdatedAt;
  3601.     }
  3602.     /**
  3603.      * Set impressionUpdatedAt.
  3604.      *
  3605.      * @param \DateTime $impressionUpdatedAt
  3606.      *
  3607.      * @return Listing
  3608.      */
  3609.     public function setImpressionUpdatedAt($impressionUpdatedAt)
  3610.     {
  3611.         $this->impressionUpdatedAt $impressionUpdatedAt;
  3612.         return $this;
  3613.     }
  3614.     public function getCompoundStatus()
  3615.     {
  3616.         return $this->compoundStatus;
  3617.     }
  3618.     public function setCompoundStatus($compoundStatus)
  3619.     {
  3620.         $this->compoundStatus $compoundStatus;
  3621.         return $this;
  3622.     }
  3623.     /**
  3624.      * @Serializer\VirtualProperty
  3625.      *
  3626.      * @Serializer\SerializedName("compound_status")
  3627.      *
  3628.      * @return string
  3629.      */
  3630.     public function getCompoundStatusLabel()
  3631.     {
  3632.         return CompoundStatus::getLabel($this->getCompoundStatus());
  3633.     }
  3634.     public function setCompoundStatusLabel($label): void
  3635.     {
  3636.         $this->compoundStatusLabel $label;
  3637.     }
  3638.     public function getPriceLevel()
  3639.     {
  3640.         return $this->priceLevel;
  3641.     }
  3642.     public function setPriceLevel($priceLevel)
  3643.     {
  3644.         $this->priceLevel $priceLevel;
  3645.         return $this;
  3646.     }
  3647.     /**
  3648.      * @Serializer\VirtualProperty
  3649.      *
  3650.      * @Serializer\SerializedName("price_level")
  3651.      *
  3652.      * @return string
  3653.      */
  3654.     public function getPriceLevelLabel()
  3655.     {
  3656.         if (!$this->getPriceLevel() && $this->hasParent()) {
  3657.             return ListingPriceLevel::getLabel($this->getParent()->getPriceLevel());
  3658.         }
  3659.         return ListingPriceLevel::getLabel($this->getPriceLevel());
  3660.     }
  3661.     /**
  3662.      * Check if the Listing desn't have the flag and fall back to the parent.
  3663.      *
  3664.      * @return string
  3665.      */
  3666.     public function isParentCommercial()
  3667.     {
  3668.         if (!$this->isCommercial() && $this->hasParent()) {
  3669.             return $this->getParent()->isCommercial();
  3670.         }
  3671.         return $this->isCommercial();
  3672.     }
  3673.     public function setPriceLevelLabel($label): void
  3674.     {
  3675.         $this->priceLevelLabel $label;
  3676.     }
  3677.     public function getPricePerMeter()
  3678.     {
  3679.         return $this->pricePerMeter;
  3680.     }
  3681.     public function setPricePerMeter($pricePerMeter)
  3682.     {
  3683.         $this->pricePerMeter $pricePerMeter;
  3684.         return $this;
  3685.     }
  3686.     public function getChildrenArea()
  3687.     {
  3688.         $result = [];
  3689.         if (empty($this->getChildren())) {
  3690.             return;
  3691.         }
  3692.         foreach ($this->getChildren() as $child) {
  3693.             $result['area'] = (int) $child->getArea();
  3694.         }
  3695.         return $result;
  3696.     }
  3697.     public function getChildrenPrice()
  3698.     {
  3699.         $result = [];
  3700.         if (empty($this->getChildren())) {
  3701.             return;
  3702.         }
  3703.         foreach ($this->getChildren() as $child) {
  3704.             $result['price'] = (int) $child->getPrice();
  3705.         }
  3706.         return $result;
  3707.     }
  3708.     public function getChildrenPricePerMeter()
  3709.     {
  3710.         $result = [];
  3711.         if (empty($this->getChildren())) {
  3712.             return;
  3713.         }
  3714.         foreach ($this->getChildren() as $child) {
  3715.             $result['pricePerMeter'] = (int) $child->getPricePerMeter();
  3716.         }
  3717.         return $result;
  3718.     }
  3719.     public function getChildrenAttributesList()
  3720.     {
  3721.         $result = [];
  3722.         if (empty($this->getChildren())) {
  3723.             return;
  3724.         }
  3725.         foreach ($this->getChildren() as $child) {
  3726.             foreach ($child->getAttributes() as $attribute) {
  3727.                 $result[$attribute->getCustomField()->getName()] = $attribute->getValue();
  3728.             }
  3729.         }
  3730.         return $result;
  3731.     }
  3732.     /**
  3733.      * Returns array of children's property types.
  3734.      */
  3735.     public function getChildrenPropertyType()
  3736.     {
  3737.         $propertyType = [];
  3738.         if (empty($this->getLiveChildren())) {
  3739.             return;
  3740.         }
  3741.         foreach ($this->getLiveChildren() as $child) {
  3742.             $propertyType['id'] = $child->getPropertyType()->getId();
  3743.         }
  3744.         return $propertyType;
  3745.     }
  3746.     /**
  3747.      * Returns array of children's property types.
  3748.      *
  3749.      * @Serializer\VirtualProperty
  3750.      *
  3751.      * @Serializer\SerializedName("childrenPropertyTypes")
  3752.      *
  3753.      * @Serializer\Groups({"locationListingV2", "homeCompoundV2"})
  3754.      *
  3755.      * @Serializer\Expose
  3756.      */
  3757.     public function getChildrenPropertyTypeTitle(): array
  3758.     {
  3759.         $propertyTypes = [];
  3760.         if (empty($this->getLiveChildren())) {
  3761.             return [];
  3762.         }
  3763.         foreach ($this->getLiveChildren() as $child) {
  3764.             $propertyTypes[] = $child->getPropertyType()->getTitle();
  3765.         }
  3766.         return array_values(array_unique($propertyTypes));
  3767.     }
  3768.     public function isBumped(): bool
  3769.     {
  3770.         return (bool) $this->isBumped;
  3771.     }
  3772.     public function setBumped(bool $status true): self
  3773.     {
  3774.         $this->isBumped $status;
  3775.         return $this;
  3776.     }
  3777.     /**
  3778.      * @return bool
  3779.      */
  3780.     public function isSendEmail()
  3781.     {
  3782.         return $this->isSendEmail;
  3783.     }
  3784.     /**
  3785.      * @return $this
  3786.      */
  3787.     public function setIsSendEmail(bool $isSendEmail true)
  3788.     {
  3789.         $this->isSendEmail $isSendEmail;
  3790.         return $this;
  3791.     }
  3792.     public function isAvailabilityEmailSentl(): bool
  3793.     {
  3794.         return $this->isAvailabilityEmailSent;
  3795.     }
  3796.     /**
  3797.      * @return $this
  3798.      */
  3799.     public function setIsAvailabilityEmailSent(bool $isAvailabilityEmailSent false)
  3800.     {
  3801.         $this->isAvailabilityEmailSent $isAvailabilityEmailSent;
  3802.         return $this;
  3803.     }
  3804.     /**
  3805.      * @Serializer\VirtualProperty()
  3806.      *
  3807.      * @Serializer\Groups({"DataLayer", "Details", "Search", "DefaultV4", "SearchV4", "listingDetails"})
  3808.      *
  3809.      * @Serializer\Expose
  3810.      *
  3811.      * @return bool
  3812.      */
  3813.     public function hasParent()
  3814.     {
  3815.         return !empty($this->parent);
  3816.     }
  3817.     /**
  3818.      * @Serializer\VirtualProperty()
  3819.      *
  3820.      * @Serializer\Groups({"Details", "Search", "DefaultV4", "SearchV4", "listingDetails"})
  3821.      *
  3822.      * @Serializer\Expose
  3823.      */
  3824.     public function isProjectOrUnit(): bool
  3825.     {
  3826.         return $this->hasParent() || $this->isProject();
  3827.     }
  3828.     /**
  3829.      * @Serializer\VirtualProperty()
  3830.      *
  3831.      * @Serializer\Groups({"DataLayer"})
  3832.      *
  3833.      * @Serializer\Expose
  3834.      */
  3835.     public function hasChildren(): bool
  3836.     {
  3837.         return $this->isProject();
  3838.     }
  3839.     /**
  3840.      * Gets Geo point.
  3841.      */
  3842.     public function getGeoPoint()
  3843.     {
  3844.         if (!$this->getCenterLat() || !$this->getCenterLng()) {
  3845.             return;
  3846.         }
  3847.         return implode(',', [$this->getCenterLat(), $this->getCenterLng()]);
  3848.     }
  3849.     /**
  3850.      * @return ArrayCollection
  3851.      */
  3852.     public function getRates(?\DateTime $startDate null)
  3853.     {
  3854.         $criteria Criteria::create()
  3855.             ->andWhere(Criteria::expr()->lt(
  3856.                 'createdAt',
  3857.                 new \DateTime()
  3858.             ))
  3859.             ->andWhere(Criteria::expr()->gt(
  3860.                 'createdAt',
  3861.                 $startDate ?? new \DateTime(sprintf('-%d Days'ListingRateConstant::DATE_RANGE_START))
  3862.             ));
  3863.         return $this->rates->matching($criteria);
  3864.     }
  3865.     /**
  3866.      * @Serializer\VirtualProperty
  3867.      *
  3868.      * @Serializer\Groups({"Rates"})
  3869.      *
  3870.      * @Serializer\Expose
  3871.      *
  3872.      * @return int
  3873.      */
  3874.     public function getTotalRates(?\DateTime $startDate null)
  3875.     {
  3876.         $totalRates $this->getRates($startDate)->count();
  3877.         if (!$totalRates) {
  3878.             return null;
  3879.         }
  3880.         return round(($this->getPositiveRatesCount($startDate) / $totalRates) * 100);
  3881.     }
  3882.     /**
  3883.      * @Serializer\VirtualProperty()
  3884.      *
  3885.      * @Serializer\Groups({"DefaultV4", "MyListing"})
  3886.      *
  3887.      * @Serializer\SerializedName("score")
  3888.      *
  3889.      * @Serializer\Expose
  3890.      */
  3891.     public function getRateScore()
  3892.     {
  3893.         return $this->getTotalRates();
  3894.     }
  3895.     public function setTotalRates($totalRates): self
  3896.     {
  3897.         $this->totalRates $totalRates;
  3898.         return $this;
  3899.     }
  3900.     /**
  3901.      * @Serializer\VirtualProperty
  3902.      *
  3903.      * @Serializer\Groups({"Rates"})
  3904.      *
  3905.      * @Serializer\SerializedName("positive_rates")
  3906.      *
  3907.      * @Serializer\Expose
  3908.      */
  3909.     public function getPositiveRatesCount(?\DateTime $startDate null)
  3910.     {
  3911.         $criteria Criteria::create()
  3912.             ->where(Criteria::expr()->eq('rate'ListingRateConstant::SATISFYING));
  3913.         return $this->getRates($startDate)->matching($criteria)->count();
  3914.     }
  3915.     /**
  3916.      * @Serializer\VirtualProperty
  3917.      *
  3918.      * @Serializer\Groups({"Rates"})
  3919.      *
  3920.      * @Serializer\SerializedName("negative_rates")
  3921.      *
  3922.      * @Serializer\Expose
  3923.      *
  3924.      * @return int
  3925.      */
  3926.     public function getNegativeRatesCount(?\DateTime $startDate null)
  3927.     {
  3928.         $criteria Criteria::create()
  3929.             ->where(Criteria::expr()->eq('rate'ListingRateConstant::UNSATISFYING));
  3930.         return $this->getRates($startDate)->matching($criteria)->count();
  3931.     }
  3932.     /**
  3933.      * @Serializer\VirtualProperty
  3934.      *
  3935.      * @Serializer\Groups({"Rates"})
  3936.      *
  3937.      * @Serializer\SerializedName("rates_reasons")
  3938.      *
  3939.      * @Serializer\Expose
  3940.      *
  3941.      * @return array
  3942.      */
  3943.     public function getRateReasonsCollection()
  3944.     {
  3945.         return $this->rateReasonsCollection;
  3946.     }
  3947.     /**
  3948.      * @return array
  3949.      */
  3950.     public function setRateReasonsCollection(array $rateReasonsCollection): self
  3951.     {
  3952.         $this->rateReasonsCollection = new ArrayCollection($rateReasonsCollection);
  3953.         return $this;
  3954.     }
  3955.     /**
  3956.      * @Serializer\VirtualProperty
  3957.      *
  3958.      * @Serializer\Groups({"Rates"})
  3959.      *
  3960.      * @Serializer\SerializedName("rates_comments")
  3961.      *
  3962.      * @Serializer\Expose
  3963.      *
  3964.      * @return array
  3965.      */
  3966.     public function getRatesComments()
  3967.     {
  3968.         $criteria Criteria::create()
  3969.             ->orderBy(['createdAt' => Criteria::DESC]);
  3970.         $comments = [];
  3971.         foreach ($this->getRates()->matching($criteria) as $rate) {
  3972.             $comments[] = $rate->getcomment();
  3973.         }
  3974.         return $comments;
  3975.     }
  3976.     public function getSynced()
  3977.     {
  3978.         return $this->synced;
  3979.     }
  3980.     /**
  3981.      * @return self
  3982.      */
  3983.     public function setSynced(bool $synced)
  3984.     {
  3985.         $this->synced $synced;
  3986.         return $this;
  3987.     }
  3988.     /**
  3989.      * @deprecated used to migrate to Skull service. Not needed anymore.
  3990.      *
  3991.      * @Serializer\VirtualProperty
  3992.      *
  3993.      * @Serializer\Groups({"Details", "Default", "ActivitiesData"})
  3994.      *
  3995.      * @Serializer\Expose
  3996.      */
  3997.     public function getReferenceId()
  3998.     {
  3999.         return $this->id;
  4000.     }
  4001.     /**
  4002.      * @param int $referenceId
  4003.      *
  4004.      * @return self
  4005.      */
  4006.     public function setReferenceId($referenceId)
  4007.     {
  4008.         $this->referenceId $referenceId;
  4009.         return $this;
  4010.     }
  4011.     public function setFeaturedTypeLabel($featuredTypeLabel): void
  4012.     {
  4013.         $this->featuredTypeLabel $featuredTypeLabel;
  4014.     }
  4015.     /**
  4016.      * @Serializer\VirtualProperty
  4017.      *
  4018.      * @Serializer\SerializedName("featuredType")
  4019.      *
  4020.      * @Serializer\Groups({"List", "Details", "listingDetails", "RelatedListingsV2"})
  4021.      *
  4022.      * @Serializer\Expose
  4023.      */
  4024.     public function getFeaturedType()
  4025.     {
  4026.         return ['type' => $this->getFeatured(), 'label' => $this->featuredTypeLabel];
  4027.     }
  4028.     /**
  4029.      * @Serializer\VirtualProperty
  4030.      *
  4031.      * @Serializer\SerializedName("featuredType")
  4032.      *
  4033.      * @Serializer\Groups({"DefaultV4", "SearchV4", "ProjectSearchV4", "locationListingV2", "MyListings"})
  4034.      */
  4035.     public function getFeaturedName()
  4036.     {
  4037.         return ListingFeaturedTypes::getFeaturedName($this->getFeatured());
  4038.     }
  4039.     /**
  4040.      * @Serializer\VirtualProperty
  4041.      *
  4042.      * @Serializer\SerializedName("referenceId")
  4043.      *
  4044.      * @Serializer\Expose()
  4045.      *
  4046.      * @Serializer\Groups({"DefaultV4", "SearchV4"})
  4047.      */
  4048.     public function getReferencedV4Id()
  4049.     {
  4050.         return $this->getId();
  4051.     }
  4052.     /**
  4053.      * @return favourite
  4054.      */
  4055.     public function getFavourite()
  4056.     {
  4057.         return $this->favourite;
  4058.     }
  4059.     public function setFavourite(array $favourites): self
  4060.     {
  4061.         foreach ($favourites as $favourite) {
  4062.             $this->addFavourite($favourites);
  4063.         }
  4064.         return $this;
  4065.     }
  4066.     /**
  4067.      * Add favourite.
  4068.      *
  4069.      * @return Listing
  4070.      */
  4071.     public function addFavourite(Favourite $favourite)
  4072.     {
  4073.         $favourite->setListing($this);
  4074.         $this->favourite[] = $favourite;
  4075.         return $this;
  4076.     }
  4077.     public function isPendingFeaturing()
  4078.     {
  4079.         return $this->isPendingFeaturing;
  4080.     }
  4081.     /**
  4082.      * @return $this
  4083.      */
  4084.     public function setPendingFeaturing($pendingFeaturing)
  4085.     {
  4086.         $this->isPendingFeaturing $pendingFeaturing;
  4087.         return $this;
  4088.     }
  4089.     public function getPendingFeaturingType()
  4090.     {
  4091.         return $this->pendingFeaturingType;
  4092.     }
  4093.     /**
  4094.      * @return Listing
  4095.      */
  4096.     public function setPendingFeaturingType($pendingFeaturingType)
  4097.     {
  4098.         $this->pendingFeaturingType $pendingFeaturingType;
  4099.         return $this;
  4100.     }
  4101.     /**
  4102.      * @Serializer\VirtualProperty
  4103.      *
  4104.      * @Serializer\SerializedName("is_favourite")
  4105.      *
  4106.      * @Serializer\Groups({"List", "Details"})
  4107.      *
  4108.      * @return bool
  4109.      */
  4110.     public function getIsFavourite()
  4111.     {
  4112.         return $this->isFavourite;
  4113.     }
  4114.     /**
  4115.      * @return Listing
  4116.      */
  4117.     public function setIsFavourite(bool $isFavourite)
  4118.     {
  4119.         $this->isFavourite $isFavourite;
  4120.         return $this;
  4121.     }
  4122.     /**
  4123.      * @Serializer\VirtualProperty
  4124.      *
  4125.      * @Serializer\SerializedName("user_note")
  4126.      *
  4127.      * @Serializer\Groups({"List", "Details"})
  4128.      *
  4129.      * @return string
  4130.      */
  4131.     public function getUserNote()
  4132.     {
  4133.         return $this->userNote;
  4134.     }
  4135.     /**
  4136.      * @return Listing
  4137.      */
  4138.     public function setUserNote(?string $userNote)
  4139.     {
  4140.         $this->userNote $userNote;
  4141.         return $this;
  4142.     }
  4143.     public function isProject(): bool
  4144.     {
  4145.         return ListingCategories::PROJECTS == $this->getCategory();
  4146.     }
  4147.     /**
  4148.      * @return int
  4149.      */
  4150.     public function getListingFeaturesFromFeaturedType()
  4151.     {
  4152.         switch ($this->getFeatured()) {
  4153.             case ListingFeaturedTypes::SPOTLIGHT:
  4154.                 return ListingFeatures::SPOTLIGHT;
  4155.             case ListingFeaturedTypes::SPONSORED:
  4156.                 return ListingFeatures::SPONSORED;
  4157.             case ListingFeaturedTypes::PREMIUM:
  4158.                 return ListingFeatures::PREMIUM;
  4159.             default:
  4160.                 return ListingFeatures::FEATURED;
  4161.         }
  4162.     }
  4163.     /**
  4164.      * @Serializer\VirtualProperty
  4165.      *
  4166.      * @Serializer\SerializedName("isExcludedFromWhatsApp")
  4167.      *
  4168.      * @Serializer\Groups({"List", "Details", "DefaultV4"})
  4169.      *
  4170.      * @return bool
  4171.      */
  4172.     public function getIsExcludedFromWhatsApp()
  4173.     {
  4174.         if (
  4175.             !empty($this->getUser()->getTeam())
  4176.             && TeamCategories::EXCLUDED_FROM_WHATSAPP == $this->getUser()->getTeam()->getCategory()
  4177.             && ListingCategories::PROJECTS == $this->getCategory()
  4178.         ) {
  4179.             return true;
  4180.         }
  4181.         return false;
  4182.     }
  4183.     /**
  4184.      * @return int|null
  4185.      */
  4186.     public function getRateStatus()
  4187.     {
  4188.         return $this->rateStatus;
  4189.     }
  4190.     /**
  4191.      * @return Listing
  4192.      */
  4193.     public function setRateStatus(?int $rateStatus)
  4194.     {
  4195.         $this->rateStatus $rateStatus;
  4196.         return $this;
  4197.     }
  4198.     /**
  4199.      * @Serializer\VirtualProperty
  4200.      *
  4201.      * @return string
  4202.      */
  4203.     public function getRateStatusLabel()
  4204.     {
  4205.         return ListingRateStatus::getLabel($this->getRateStatus());
  4206.     }
  4207.     /**
  4208.      * @return boolean||null
  4209.      */
  4210.     public function getIsRateReviewed()
  4211.     {
  4212.         return $this->isRateReviewed;
  4213.     }
  4214.     /**
  4215.      * @return Listing
  4216.      */
  4217.     public function setIsRateReviewed(?bool $isRateReviewed)
  4218.     {
  4219.         $this->isRateReviewed $isRateReviewed;
  4220.         return $this;
  4221.     }
  4222.     /**
  4223.      * @Serializer\VirtualProperty
  4224.      */
  4225.     public function getRateReviewStatusLabel(): string
  4226.     {
  4227.         return ListingRateReviewStatus::getLabel($this->getIsRateReviewed() ? ListingRateReviewStatus::REVIEWED ListingRateReviewStatus::PENDING_REVIEW);
  4228.     }
  4229.     /**
  4230.      * @Serializer\VirtualProperty
  4231.      *
  4232.      * @Serializer\Groups({"Rates"})
  4233.      *
  4234.      * @Serializer\SerializedName("reported_date")
  4235.      *
  4236.      * @Serializer\Expose
  4237.      *
  4238.      * @return array
  4239.      */
  4240.     public function getReportedDate()
  4241.     {
  4242.         return $this->reportedDate;
  4243.     }
  4244.     /**
  4245.      * @param \DateTime|string $reportedDate
  4246.      *
  4247.      * @return array
  4248.      */
  4249.     public function setReportedDate($reportedDate): self
  4250.     {
  4251.         $this->reportedDate $reportedDate;
  4252.         return $this;
  4253.     }
  4254.     /**
  4255.      * @return array
  4256.      */
  4257.     public function getReasonIds()
  4258.     {
  4259.         $rateReasonsCollection $this->getRateReasonsCollection();
  4260.         if (!isset($rateReasonsCollection['reason_ids'])) {
  4261.             return [];
  4262.         }
  4263.         $reasonsIds = [];
  4264.         foreach ($rateReasonsCollection['reason_ids'] as $key => $value) {
  4265.             $reasonsIds[] = [
  4266.                 'key' => $key,
  4267.                 'value' => $value,
  4268.             ];
  4269.         }
  4270.         return $reasonsIds;
  4271.     }
  4272.     /**
  4273.      * @return array
  4274.      */
  4275.     public function getReasonLabels()
  4276.     {
  4277.         $rateReasonsCollection $this->getRateReasonsCollection();
  4278.         if (!isset($rateReasonsCollection['reason_labels'])) {
  4279.             return [];
  4280.         }
  4281.         $reasonLabels = [];
  4282.         foreach ($rateReasonsCollection['reason_labels'] as $label => $count) {
  4283.             $reasonLabels[] = [
  4284.                 'label' => $label,
  4285.                 'count' => $count,
  4286.             ];
  4287.         }
  4288.         return $reasonLabels;
  4289.     }
  4290.     private function listMainListingPhonesFromUser(): ArrayCollection
  4291.     {
  4292.         $phones = new ArrayCollection();
  4293.         if ($this->getUser()) {
  4294.             foreach ($this->getUser()->getMainPhones(UserMainPhones::BUILD_FORMATTER_USER_PHONES) as $phone) {
  4295.                 if ($phone) {
  4296.                     $phones->add($this->castUserPhonesAsListingPhones($phone));
  4297.                 }
  4298.             }
  4299.         }
  4300.         return $phones;
  4301.     }
  4302.     private function castUserPhonesAsListingPhones(UserPhone $userPhone): ListingPhone
  4303.     {
  4304.         $phone $userPhone->getPhone();
  4305.         $phone->setWhatsApp($userPhone->isWhatsApp());
  4306.         return new ListingPhone(
  4307.             convert_arabic_numbers($phone->getNumber()),
  4308.             $this,
  4309.             $phone->getCountryCode(),
  4310.             $phone
  4311.         );
  4312.     }
  4313.     /**
  4314.      * @param Listing $parentOfSimilarListing
  4315.      *
  4316.      * @return Listing
  4317.      */
  4318.     public function setParentOfSimilarListing($parentOfSimilarListing)
  4319.     {
  4320.         $this->parentOfSimilarListing $parentOfSimilarListing;
  4321.         return $this;
  4322.     }
  4323.     /**
  4324.      * @Serializer\VirtualProperty
  4325.      *
  4326.      * @Serializer\SerializedName("parentOfSimilarListing")
  4327.      *
  4328.      * @Serializer\Groups({"SimilarListings"})
  4329.      *
  4330.      * @Serializer\Expose()
  4331.      *
  4332.      * @return Listing
  4333.      */
  4334.     public function getParentOfSimilarListing()
  4335.     {
  4336.         return $this->parentOfSimilarListing;
  4337.     }
  4338.     public function isCallRequest(): bool
  4339.     {
  4340.         return $this->isCallRequest;
  4341.     }
  4342.     public function setIsCallRequest(bool $isCallRequest): self
  4343.     {
  4344.         $this->isCallRequest $isCallRequest;
  4345.         return $this;
  4346.     }
  4347.     public function getNotMigratedFields()
  4348.     {
  4349.         return [
  4350.             'impressionUpdatedAt',
  4351.             'impressions',
  4352.         ];
  4353.     }
  4354.     public function generateCoordinates(): self
  4355.     {
  4356.         if ($this->getLocation() && (!$this->centerLat || !$this->centerLng)) {
  4357.             /** @var Location $location */
  4358.             $location $this->location;
  4359.             $this->setCenterLat($location->getLat());
  4360.             $this->setCenterLng($location->getLon());
  4361.         }
  4362.         return $this;
  4363.     }
  4364.     public function buildListingAttributes(): self
  4365.     {
  4366.         /** @var ListingAttribute $attribute */
  4367.         foreach ($this->attributes as $attribute) {
  4368.             if (!$attribute->getCustomField() instanceof CustomField) {
  4369.                 continue;
  4370.             }
  4371.             $attributeName $attribute->getFormattedAttributeName();
  4372.             $attributeValue $attribute->getValue();
  4373.             if (null != $attributeValue) {
  4374.                 $this->listingAttributes[$attributeName] = $attributeValue;
  4375.             }
  4376.             if (ListingCustomFields::FINISH_TYPE_VALUE == $attributeName) {
  4377.                 $this->listingAttributes[ListingCustomFields::FINISH_TYPE_LABEL_VALUE] = $attributeValue;
  4378.             }
  4379.         }
  4380.         return $this;
  4381.     }
  4382.     /**
  4383.      * @Serializer\VirtualProperty
  4384.      *
  4385.      * @Serializer\SerializedName("attributes")
  4386.      *
  4387.      * @Serializer\Groups({"DefaultV4", "SearchV4", "RelatedListingsV2", "MyListings"})
  4388.      *
  4389.      * @Serializer\Expose()
  4390.      *
  4391.      * @return array
  4392.      */
  4393.     public function getListingAttributesList()
  4394.     {
  4395.         if (empty($this->listingAttributes)) {
  4396.             return null;
  4397.         }
  4398.         return $this->listingAttributes;
  4399.     }
  4400.     /**
  4401.      * @return array
  4402.      */
  4403.     public function setListingAttributesList(array $attributesList)
  4404.     {
  4405.         $this->listingAttributes $attributesList;
  4406.         return $this->listingAttributes;
  4407.     }
  4408.     /**
  4409.      * @Serializer\VirtualProperty
  4410.      *
  4411.      * @Serializer\SerializedName("latitude")
  4412.      *
  4413.      * @Serializer\Groups({"DefaultV4", "SearchV4", "RelatedListingsV2"})
  4414.      *
  4415.      * @Serializer\Expose()
  4416.      *
  4417.      * @return float
  4418.      */
  4419.     public function getLatitude()
  4420.     {
  4421.         return $this->centerLat;
  4422.     }
  4423.     /**
  4424.      * @Serializer\VirtualProperty
  4425.      *
  4426.      * @Serializer\SerializedName("longitude")
  4427.      *
  4428.      * @Serializer\Groups({"DefaultV4", "SearchV4", "RelatedListingsV2"})
  4429.      *
  4430.      * @Serializer\Expose()
  4431.      *
  4432.      * @return float
  4433.      */
  4434.     public function getLongitude()
  4435.     {
  4436.         return $this->centerLng;
  4437.     }
  4438.     /**
  4439.      * @Serializer\VirtualProperty
  4440.      *
  4441.      * @Serializer\SerializedName("status")
  4442.      *
  4443.      * @Serializer\Groups({"DefaultV4", "MyListing", "MyListings"})
  4444.      *
  4445.      * @Serializer\Expose()
  4446.      *
  4447.      * @return string
  4448.      */
  4449.     public function getLabeledStatus()
  4450.     {
  4451.         return ListingStatus::getName($this->getStatus());
  4452.     }
  4453.     /**
  4454.      * @Serializer\SerializedName("propertyViewLabel")
  4455.      *
  4456.      * @Serializer\VirtualProperty()
  4457.      *
  4458.      * @Serializer\Groups({"DefaultV4","SearchV4"})
  4459.      *
  4460.      * @Serializer\Expose()
  4461.      */
  4462.     public function getTranslatedPropertyViewLabel()
  4463.     {
  4464.         return $this->propertyViewLabel;
  4465.     }
  4466.     /**
  4467.      * @Serializer\SerializedName("paymentMethodLabel")
  4468.      *
  4469.      * @Serializer\VirtualProperty()
  4470.      *
  4471.      * @Serializer\Groups({"DefaultV4"})
  4472.      *
  4473.      * @Serializer\Expose()
  4474.      */
  4475.     public function getTranslatedPaymentMethodLabel()
  4476.     {
  4477.         return $this->getPaymentMethodLabelTranslated();
  4478.     }
  4479.     /**
  4480.      * @Serializer\SerializedName("paymentMethod")
  4481.      *
  4482.      * @Serializer\VirtualProperty()
  4483.      *
  4484.      * @Serializer\Groups({"DefaultV4"})
  4485.      *
  4486.      * @Serializer\Expose()
  4487.      */
  4488.     public function getPaymentMethodText()
  4489.     {
  4490.         return ListingPaymentMethod::getText($this->paymentMethod);
  4491.     }
  4492.     /**
  4493.      * @Serializer\SerializedName("sellerRole")
  4494.      *
  4495.      * @Serializer\VirtualProperty()
  4496.      *
  4497.      * @Serializer\Groups({"Details", "DefaultV4", "SearchV4"})
  4498.      *
  4499.      * @Serializer\Expose()
  4500.      */
  4501.     public function getSellerRoleText()
  4502.     {
  4503.         return ListingSellerRoles::getName($this->getSellerRole());
  4504.     }
  4505.     public function generateAddress(): self
  4506.     {
  4507.         if ($this->address || !$this->location) {
  4508.             return $this;
  4509.         }
  4510.         $this->setAddress($this->getLocation()->getTitleFullPath());
  4511.         return $this;
  4512.     }
  4513.     public function setIsPriceNegotiable(bool $isPriceNegotiable, ?CustomField $isPriceNegotiableAttribute null): self
  4514.     {
  4515.         if (!$isPriceNegotiableAttribute) {
  4516.             return $this;
  4517.         }
  4518.         /** @var ListingAttribute $attribute */
  4519.         foreach ($this->attributes as $attribute) {
  4520.             if ($attribute->getCustomField()->getId() === $isPriceNegotiableAttribute->getId()) {
  4521.                 $attribute->setValue($isPriceNegotiable);
  4522.                 return $this;
  4523.             }
  4524.         }
  4525.         $listingAttribute = new ListingAttribute();
  4526.         $listingAttribute->setCustomField($isPriceNegotiableAttribute);
  4527.         $listingAttribute->setValue($isPriceNegotiable);
  4528.         $this->addAttribute($listingAttribute);
  4529.         return $this;
  4530.     }
  4531.     /**
  4532.      * @Serializer\SerializedName("isPriceNegotiable")
  4533.      *
  4534.      * @Serializer\VirtualProperty()
  4535.      *
  4536.      * @Serializer\Groups({"DefaultV4", "SearchV4"})
  4537.      *
  4538.      * @Serializer\Expose()
  4539.      */
  4540.     public function getIsPriceNegotiable(): bool
  4541.     {
  4542.         /** @var ListingAttribute $attribute */
  4543.         foreach ($this->attributes as $attribute) {
  4544.             if (ListingCustomFields::IS_NEGOTIABLE_NAME === $attribute->getCustomField()->getName()) {
  4545.                 return true;
  4546.             }
  4547.         }
  4548.         return false;
  4549.     }
  4550.     /**
  4551.      * @Serializer\VirtualProperty()
  4552.      *
  4553.      * @Serializer\Groups({"Statistics"})
  4554.      *
  4555.      * @Serializer\SerializedName("clickRate")
  4556.      *
  4557.      * @Serializer\Expose()
  4558.      */
  4559.     public function getClickRate(): float
  4560.     {
  4561.         $impressions $this->getImpressions() > $this->getImpressions() : 1;
  4562.         return round(($this->getViews() / $impressions) * 1002);
  4563.     }
  4564.     /**
  4565.      * @return int|null
  4566.      *
  4567.      * @Serializer\VirtualProperty()
  4568.      *
  4569.      * @Serializer\Groups({"Statistics"})
  4570.      *
  4571.      * @Serializer\SerializedName("contactRate")
  4572.      *
  4573.      * @Serializer\Expose()
  4574.      *
  4575.      * @return float|int
  4576.      */
  4577.     public function getContactRate()
  4578.     {
  4579.         return ($this->getLeadsCounter() / ($this->getViewsCount() ?: 1)) * 100;
  4580.     }
  4581.     /**
  4582.      * @return float|int
  4583.      */
  4584.     public function getComputedContactRate()
  4585.     {
  4586.         if (empty($this->leadsCounter) || empty($this->views)) {
  4587.             return 0;
  4588.         }
  4589.         return round($this->leadsCounter $this->views 1002);
  4590.     }
  4591.     /**
  4592.      * @param float
  4593.      *
  4594.      * @return self
  4595.      */
  4596.     public function setContactRate(float $contactRate)
  4597.     {
  4598.         $this->contactRate $contactRate;
  4599.         return $this;
  4600.     }
  4601.     /**
  4602.      * @Serializer\VirtualProperty()
  4603.      *
  4604.      * @Serializer\Groups({"Statistics", "MyListing"})
  4605.      *
  4606.      * @Serializer\SerializedName("impressionsCount")
  4607.      *
  4608.      * @Serializer\Expose()
  4609.      *
  4610.      * @return float|int
  4611.      */
  4612.     public function getImpressionsCount()
  4613.     {
  4614.         return $this->getImpressions() ?: 0;
  4615.     }
  4616.     /**
  4617.      * @Serializer\VirtualProperty()
  4618.      *
  4619.      * @Serializer\Groups({"Statistics", "MyListing", "MyListings"})
  4620.      *
  4621.      * @Serializer\SerializedName("viewsCount")
  4622.      *
  4623.      * @Serializer\Expose()
  4624.      *
  4625.      * @return float|int
  4626.      */
  4627.     public function getViewsCount()
  4628.     {
  4629.         return $this->getViews() ?: 0;
  4630.     }
  4631.     /**
  4632.      * @Serializer\VirtualProperty()
  4633.      *
  4634.      * @Serializer\Groups({"Statistics", "MyListing", "MyListings"})
  4635.      *
  4636.      * @Serializer\SerializedName("leadsCount")
  4637.      *
  4638.      * @Serializer\Expose()
  4639.      *
  4640.      * @return float|int
  4641.      */
  4642.     public function getLeadCount()
  4643.     {
  4644.         return $this->getLeadsCounter() ?: 0;
  4645.     }
  4646.     /**
  4647.      * @return int|null
  4648.      */
  4649.     public function isCommercial()
  4650.     {
  4651.         return $this->isCommercial;
  4652.     }
  4653.     public function setIsCommercial(int $isCommercial): void
  4654.     {
  4655.         $this->isCommercial $isCommercial;
  4656.     }
  4657.     /**
  4658.      * @Serializer\VirtualProperty()
  4659.      *
  4660.      * @Serializer\Groups({"DefaultV4", "SearchV4"})
  4661.      *
  4662.      * @Serializer\SerializedName("category")
  4663.      *
  4664.      * @Serializer\Expose()
  4665.      *
  4666.      * @return string|null
  4667.      */
  4668.     public function getCategoryByName()
  4669.     {
  4670.         return ListingCategories::getLabel($this->getCategory());
  4671.     }
  4672.     /**
  4673.      * @Serializer\VirtualProperty()
  4674.      *
  4675.      * @Serializer\Groups({"Default", "Details", "listingDetails"})
  4676.      *
  4677.      * @Serializer\SerializedName("categoryLabel")
  4678.      *
  4679.      * @Serializer\Expose()
  4680.      */
  4681.     public function getCategoryLabel(): ?string
  4682.     {
  4683.         return $this->getCategoryName();
  4684.     }
  4685.     /**
  4686.      * @Serializer\VirtualProperty()
  4687.      *
  4688.      * @Serializer\Groups({"Statistics", "MyListing"})
  4689.      *
  4690.      * @Serializer\SerializedName("messagesCount")
  4691.      *
  4692.      * @Serializer\Expose()
  4693.      *
  4694.      * @return int|null
  4695.      */
  4696.     public function getMessagesCount()
  4697.     {
  4698.         return $this->getMessagesCounter() ?: 0;
  4699.     }
  4700.     /**
  4701.      * Get WhatsApp Number.
  4702.      *
  4703.      * @Serializer\VirtualProperty
  4704.      *
  4705.      * @Serializer\SerializedName("whatsAppNumber")
  4706.      *
  4707.      * @Serializer\Groups({"DefaultV4", "SearchV4", "ProjectDetailsV4", "ProjectSearchV4", "RelatedListingsV2", "locationListingV2", "listingDetails"})
  4708.      */
  4709.     public function getWhatsAppNumber()
  4710.     {
  4711.         $user $this->getUser();
  4712.         if ($user->getWhatsAppNumber()) {
  4713.             $whatsAppNumber $user->getWhatsAppNumber()->getNumber();
  4714.             if (!preg_match('/^\+\d+$/'$whatsAppNumber)) {
  4715.                 return $user->getCountryCode().$whatsAppNumber;
  4716.             }
  4717.             return $whatsAppNumber;
  4718.         }
  4719.         return null;
  4720.     }
  4721.     public function getTranslatableLocale()
  4722.     {
  4723.         return $this->locale;
  4724.     }
  4725.     /**
  4726.      * @return Listing
  4727.      */
  4728.     public function setV4Translations($translations)
  4729.     {
  4730.         $this->v4Translations $translations;
  4731.         return $this;
  4732.     }
  4733.     /**
  4734.      * Get translations.
  4735.      *
  4736.      * @Serializer\VirtualProperty
  4737.      *
  4738.      * @Serializer\Groups({"DefaultV4", "MyListing"})
  4739.      *
  4740.      * @Serializer\SerializedName("translations")
  4741.      *
  4742.      * @Serializer\Expose
  4743.      *
  4744.      * @return array
  4745.      */
  4746.     public function getV4Translations()
  4747.     {
  4748.         return $this->v4Translations;
  4749.     }
  4750.     /**
  4751.      * @Serializer\VirtualProperty
  4752.      *
  4753.      * @Serializer\Groups({"DefaultV4", "MyListing", "MyListings"})
  4754.      *
  4755.      * @Serializer\Expose
  4756.      *
  4757.      * @return ArrayCollection
  4758.      */
  4759.     public function getRejectionReasons()
  4760.     {
  4761.         return $this->rejections;
  4762.     }
  4763.     /**
  4764.      * @return array
  4765.      */
  4766.     public function getExistingTranslationsLanguages()
  4767.     {
  4768.         $existingLanguages = [];
  4769.         /** @var ListingTranslation $translation */
  4770.         foreach ($this->getTranslations() as $translation) {
  4771.             if ((!('title' == $translation->getField() || 'description' == $translation->getField()))
  4772.                 || \in_array($translation->getLocale(), $existingLanguages) || !$translation->getContent()
  4773.             ) {
  4774.                 continue;
  4775.             }
  4776.             $existingLanguages[] = $translation->getLocale();
  4777.         }
  4778.         return $existingLanguages;
  4779.     }
  4780.     public function isShownInHomepage(): bool
  4781.     {
  4782.         return $this->isShownInHomepage;
  4783.     }
  4784.     public function setIsShownInHomepage(bool $isShownInHomepage): self
  4785.     {
  4786.         $this->isShownInHomepage $isShownInHomepage;
  4787.         return $this;
  4788.     }
  4789.     public function isResale(): bool
  4790.     {
  4791.         return $this->isResale;
  4792.     }
  4793.     public function setIsResale(bool $isResale): self
  4794.     {
  4795.         $this->isResale $isResale;
  4796.         return $this;
  4797.     }
  4798.     public function setIsRent(bool $isRent): self
  4799.     {
  4800.         $this->isRent $isRent;
  4801.         return $this;
  4802.     }
  4803.     public function isRent(): bool
  4804.     {
  4805.         return $this->isRent;
  4806.     }
  4807.     public function setIsPrimary(bool $isPrimary): self
  4808.     {
  4809.         $this->isPrimary $isPrimary;
  4810.         return $this;
  4811.     }
  4812.     public function isPrimary(): bool
  4813.     {
  4814.         return $this->isPrimary;
  4815.     }
  4816.     /**
  4817.      * @return boolean||null
  4818.      */
  4819.     public function getIsMortgageApproved()
  4820.     {
  4821.         return $this->isMortgageApproved;
  4822.     }
  4823.     public function setIsMortgageApproved(?bool $isMortgageApproved): self
  4824.     {
  4825.         $this->isMortgageApproved $isMortgageApproved;
  4826.         return $this;
  4827.     }
  4828.     public function getRatesNotes()
  4829.     {
  4830.         return $this->ratesNotes;
  4831.     }
  4832.     public function getRatesNote()
  4833.     {
  4834.         if ($this->ratesNotes->isEmpty()) {
  4835.             return null;
  4836.         }
  4837.         return $this->ratesNotes->last();
  4838.     }
  4839.     public function setRatesNotes($ratesNotes): void
  4840.     {
  4841.         $this->ratesNotes $ratesNotes;
  4842.     }
  4843.     public function getMetaTitle(): ?string
  4844.     {
  4845.         return $this->metaTitle;
  4846.     }
  4847.     public function setMetaTitle(?string $metaTitle): self
  4848.     {
  4849.         $this->metaTitle $metaTitle;
  4850.         return $this;
  4851.     }
  4852.     public function getMetaDescription(): ?string
  4853.     {
  4854.         return $this->metaDescription;
  4855.     }
  4856.     public function setMetaDescription(?string $metaDescription): self
  4857.     {
  4858.         $this->metaDescription $metaDescription;
  4859.         return $this;
  4860.     }
  4861.     public function getIsMortgage(): bool
  4862.     {
  4863.         return $this->isMortgage;
  4864.     }
  4865.     public function setIsMortgage(bool $isMortgage): self
  4866.     {
  4867.         $this->isMortgage $isMortgage;
  4868.         return $this;
  4869.     }
  4870.     /**
  4871.      * @Serializer\VirtualProperty()
  4872.      *
  4873.      * @Serializer\SerializedName("compound_field")
  4874.      *
  4875.      * @Serializer\Groups({"Default", "DefaultV4","ProjectSearchV4", "ProjectDetailsV4", "locationListingV2", "homeCompoundV2"})
  4876.      *
  4877.      * @Serializer\Expose
  4878.      */
  4879.     public function getCompoundField(): ?CompoundField
  4880.     {
  4881.         $compoundField $this->compoundField;
  4882.         if ($this->hasParent()) {
  4883.             $compoundField $this->getParent()->getCompoundField();
  4884.         }
  4885.         return $compoundField;
  4886.     }
  4887.     public function setCompoundField(?CompoundField $compoundField): void
  4888.     {
  4889.         $this->compoundField $compoundField;
  4890.     }
  4891.     /**
  4892.      * @return array|null
  4893.      */
  4894.     public function getEligibleForMortgage()
  4895.     {
  4896.         return $this->eligibleForMortgage;
  4897.     }
  4898.     public function setEligibleForMortgage(?array $eligibleForMortgage null): self
  4899.     {
  4900.         $this->eligibleForMortgage $eligibleForMortgage;
  4901.         return $this;
  4902.     }
  4903.     public function setPropertyRegistrationStatusOptions(?array $propertyRegistrationStatusOptions null): self
  4904.     {
  4905.         $this->propertyRegistrationStatusOptions $propertyRegistrationStatusOptions;
  4906.         return $this;
  4907.     }
  4908.     /**
  4909.      * Get Mortgage Options.
  4910.      *
  4911.      * @return array|null
  4912.      *
  4913.      * @Serializer\VirtualProperty()
  4914.      *
  4915.      * @Serializer\Groups({"DefaultV4"})
  4916.      *
  4917.      * @Serializer\SerializedName("property_registration_status_options")
  4918.      *
  4919.      * @Serializer\Expose
  4920.      */
  4921.     public function getPropertyRegistrationStatusOptions()
  4922.     {
  4923.         return $this->propertyRegistrationStatusOptions;
  4924.     }
  4925.     /**
  4926.      * @return bool
  4927.      */
  4928.     public function hasPropertyRegistrationStatusOptions()
  4929.     {
  4930.         if (!$this->getSection() || !$this->getLocation()) {
  4931.             return false;
  4932.         }
  4933.         return $this->getLocation()->getEligibleForMortgage()
  4934.             && (ListingSections::FOR_SALE == $this->getSection()->getId());
  4935.     }
  4936.     /**
  4937.      * Get Eligible For Mortgage Data.
  4938.      *
  4939.      * @return array|null
  4940.      *
  4941.      * @Serializer\VirtualProperty()
  4942.      *
  4943.      * @Serializer\Groups({"DefaultV4", "SearchV4", "Default", "listingDetails"})
  4944.      *
  4945.      * @Serializer\SerializedName("eligibleForMortgageData")
  4946.      *
  4947.      * @Serializer\Expose
  4948.      */
  4949.     public function getEligibleForMortgageData()
  4950.     {
  4951.         return $this->eligibleForMortgageData;
  4952.     }
  4953.     public function setEligibleForMortgageData(?array $eligibleForMortgageData null): self
  4954.     {
  4955.         $this->eligibleForMortgageData $eligibleForMortgageData;
  4956.         return $this;
  4957.     }
  4958.     /**
  4959.      * Get Eligible For Mortgage with Label.
  4960.      *
  4961.      * @return array
  4962.      */
  4963.     public function getEligibleForMortgageWithLabel()
  4964.     {
  4965.         $eligibleForMortgageWithLabel = [];
  4966.         if (!empty($this->getEligibleForMortgage())) {
  4967.             foreach ($this->getEligibleForMortgage() as $mortgage) {
  4968.                 $eligibleForMortgageWithLabel[] = [
  4969.                     'id' => $mortgage,
  4970.                     'title' => EligibleForMortgageData::getLabel($mortgage),
  4971.                 ];
  4972.             }
  4973.         }
  4974.         return $eligibleForMortgageWithLabel;
  4975.     }
  4976.     /**
  4977.      * @return PropertyTypeChildren
  4978.      */
  4979.     public function setPropertyTypeChildren($propertyTypeChilden)
  4980.     {
  4981.         $this->propertyTypeChilden $propertyTypeChilden;
  4982.         return $this;
  4983.     }
  4984.     /**
  4985.      * Get PropertyTypeChildren.
  4986.      *
  4987.      * @return array
  4988.      */
  4989.     public function getPropertyTypeChildren()
  4990.     {
  4991.         return $this->propertyTypeChilden;
  4992.     }
  4993.     /**
  4994.      * @return float
  4995.      */
  4996.     public function getCompoundElasticScore()
  4997.     {
  4998.         return $this->compoundElasticScore;
  4999.     }
  5000.     /**
  5001.      * @param float $compoundElasticScore
  5002.      *
  5003.      * @return Listing
  5004.      */
  5005.     public function setCompoundElasticScore($compoundElasticScore)
  5006.     {
  5007.         $this->compoundElasticScore $compoundElasticScore;
  5008.         return $this;
  5009.     }
  5010.     /**.
  5011.      * @return int|null
  5012.      */
  5013.     public function getPropertyRegistrationStatus()
  5014.     {
  5015.         return $this->propertyRegistrationStatus;
  5016.     }
  5017.     public function setPropertyRegistrationStatus(?int $propertyRegistrationStatus): self
  5018.     {
  5019.         $this->propertyRegistrationStatus $propertyRegistrationStatus;
  5020.         return $this;
  5021.     }
  5022.     /**
  5023.      * Get property registration status data options.
  5024.      *
  5025.      * @return array|null
  5026.      *
  5027.      * @Serializer\VirtualProperty()
  5028.      *
  5029.      * @Serializer\Groups({"List", "Details", "Search", "DefaultV4", "SearchV4"})
  5030.      *
  5031.      * @Serializer\SerializedName("property_registration_status_data")
  5032.      *
  5033.      * @Serializer\Expose
  5034.      */
  5035.     public function getPropertyRegistrationStatusData()
  5036.     {
  5037.         if (empty($this->propertyRegistrationStatus)) {
  5038.             return null;
  5039.         }
  5040.         return [
  5041.             'id' => $this->propertyRegistrationStatus,
  5042.             'title' => PropertyRegistrationStatusOption::getLabel($this->propertyRegistrationStatus),
  5043.         ];
  5044.     }
  5045.     /**
  5046.      * @Serializer\VirtualProperty()
  5047.      *
  5048.      * @Serializer\Groups({"Details", "DefaultV4","SearchV4"})
  5049.      *
  5050.      * @Serializer\SerializedName("financialAidURL")
  5051.      *
  5052.      * @Serializer\Expose
  5053.      */
  5054.     public function getFinancialAidURL(): ?string
  5055.     {
  5056.         // Deprecated. Return null for now.
  5057.         return null;
  5058.     }
  5059.     public function setFinancialAid(FinancialAid $financialAid): void
  5060.     {
  5061.         $this->financialAid $financialAid;
  5062.     }
  5063.     /**
  5064.      * @return bool
  5065.      */
  5066.     public function isExcludedFromClientServed()
  5067.     {
  5068.         $user $this->getUser();
  5069.         if ($user && $user->hasRole('ROLE_HOME_EG')) {
  5070.             return true;
  5071.         }
  5072.         return false;
  5073.     }
  5074.     /**
  5075.      * @Serializer\VirtualProperty()
  5076.      *
  5077.      * @Serializer\Groups({"Details", "DefaultV4","SearchV4"})
  5078.      *
  5079.      * @Serializer\SerializedName("hasSimilarListings")
  5080.      *
  5081.      * @Serializer\Expose
  5082.      */
  5083.     public function hasSimilarListings(): bool
  5084.     {
  5085.         return !empty($this->getSimilarListingsCount());
  5086.     }
  5087.     /**
  5088.      * @Serializer\VirtualProperty()
  5089.      *
  5090.      * @Serializer\Groups({"Details", "DefaultV4","SearchV4"})
  5091.      *
  5092.      * @Serializer\SerializedName("similarListingsCount")
  5093.      *
  5094.      * @Serializer\Expose
  5095.      */
  5096.     public function getSimilarListingsCount(): int
  5097.     {
  5098.         return $this->similarListingsCount;
  5099.     }
  5100.     public function setSimilarListingsCount(int $count): self
  5101.     {
  5102.         $this->similarListingsCount $count;
  5103.         return $this;
  5104.     }
  5105.     /**
  5106.      * Set similar listings ids.
  5107.      */
  5108.     public function setSimilarListingsIds(array $arrayOfIds): self
  5109.     {
  5110.         $this->similarListingsIds $arrayOfIds;
  5111.         return $this;
  5112.     }
  5113.     /**
  5114.      * @Serializer\VirtualProperty()
  5115.      *
  5116.      * @Serializer\Groups({"Details", "DefaultV4","SearchV4"})
  5117.      *
  5118.      * @Serializer\SerializedName("similarListingsIds")
  5119.      *
  5120.      * @Serializer\Expose
  5121.      */
  5122.     public function getSimilarListingsIds(): array
  5123.     {
  5124.         return $this->similarListingsIds;
  5125.     }
  5126.     public function getAdvertiserNumber(): ?string
  5127.     {
  5128.         return $this->advertiserNumber;
  5129.     }
  5130.     public function setAdvertiserNumber(?string $advertiserNumber): void
  5131.     {
  5132.         $this->advertiserNumber $advertiserNumber;
  5133.     }
  5134.     public function getAuthorizationNumber(): ?string
  5135.     {
  5136.         return $this->authorizationNumber;
  5137.     }
  5138.     public function setAuthorizationNumber(?string $authorizationNumber): void
  5139.     {
  5140.         $this->authorizationNumber $authorizationNumber;
  5141.     }
  5142.     /**
  5143.      * Get the value of marketPropertyType.
  5144.      *
  5145.      * @return int|null
  5146.      */
  5147.     public function getMarketPropertyType()
  5148.     {
  5149.         return $this->marketPropertyType;
  5150.     }
  5151.     /**
  5152.      * Set the value of marketPropertyType.
  5153.      *
  5154.      * @return self
  5155.      */
  5156.     public function setMarketPropertyType(?int $marketPropertyType)
  5157.     {
  5158.         $this->marketPropertyType $marketPropertyType;
  5159.         return $this;
  5160.     }
  5161.     /**
  5162.      * Get the value of creationSource.
  5163.      *
  5164.      * @return int
  5165.      */
  5166.     public function getCreationSource()
  5167.     {
  5168.         return $this->creationSource;
  5169.     }
  5170.     /**
  5171.      * Set the value of creationSource.
  5172.      *
  5173.      * @return self
  5174.      */
  5175.     public function setCreationSource(int $creationSource)
  5176.     {
  5177.         $this->creationSource $creationSource;
  5178.         return $this;
  5179.     }
  5180.     /**
  5181.      * @return float
  5182.      *
  5183.      * @Serializer\VirtualProperty()
  5184.      *
  5185.      * @Serializer\Groups({"Statistics", "MyListings"})
  5186.      *
  5187.      * @Serializer\SerializedName("costPerLead")
  5188.      *
  5189.      * @Serializer\Expose
  5190.      */
  5191.     public function getCostPerLead()
  5192.     {
  5193.         return $this->costPerLead;
  5194.     }
  5195.     /**
  5196.      * Set the value of costPerLead.
  5197.      *
  5198.      * @return self
  5199.      */
  5200.     public function setCostPerLead(float $costPerLead)
  5201.     {
  5202.         $this->costPerLead $costPerLead;
  5203.         return $this;
  5204.     }
  5205.     /**
  5206.      * Get the value of resaleCount.
  5207.      *
  5208.      * @return int
  5209.      */
  5210.     public function getResaleCount()
  5211.     {
  5212.         return $this->resaleCount;
  5213.     }
  5214.     /**
  5215.      * Set the value of resaleCount.
  5216.      *
  5217.      * @return self
  5218.      */
  5219.     public function setResaleCount(int $resaleCount)
  5220.     {
  5221.         $this->resaleCount $resaleCount;
  5222.         return $this;
  5223.     }
  5224.     /**
  5225.      * Get the value of resaleCount.
  5226.      *
  5227.      * @return int
  5228.      */
  5229.     public function getRentCount()
  5230.     {
  5231.         return $this->rentCount;
  5232.     }
  5233.     /**
  5234.      * Set the value of rentCount.
  5235.      *
  5236.      * @return self
  5237.      */
  5238.     public function setRentCount(int $rentCount)
  5239.     {
  5240.         $this->rentCount $rentCount;
  5241.         return $this;
  5242.     }
  5243.     /**
  5244.      * Get the value of clickThroughRate.
  5245.      */
  5246.     public function getClickThroughRate(): float
  5247.     {
  5248.         return $this->getClickRate();
  5249.     }
  5250.     /**
  5251.      * Set the value of clickThroughRate.
  5252.      */
  5253.     public function setClickThroughRate(float $clickThroughRate): self
  5254.     {
  5255.         $this->clickThroughRate $clickThroughRate;
  5256.         return $this;
  5257.     }
  5258.     /**
  5259.      * Get the value of label.
  5260.      *
  5261.      * @return int
  5262.      */
  5263.     public function getLabel()
  5264.     {
  5265.         return $this->label;
  5266.     }
  5267.     /**
  5268.      * Set the value of label.
  5269.      *
  5270.      * @return self
  5271.      */
  5272.     public function setLabel($label)
  5273.     {
  5274.         $this->label $label;
  5275.         return $this;
  5276.     }
  5277.     /**
  5278.      * Get the value of isTopPicks.
  5279.      */
  5280.     public function getIsTopPicks()
  5281.     {
  5282.         return $this->isTopPicks;
  5283.     }
  5284.     /**
  5285.      * Set the value of isTopPicks.
  5286.      *
  5287.      * @return self
  5288.      */
  5289.     public function setIsTopPicks($isTopPicks)
  5290.     {
  5291.         $this->isTopPicks $isTopPicks;
  5292.         return $this;
  5293.     }
  5294.     /**
  5295.      * Get freezedAt date.
  5296.      *
  5297.      * @return \DateTime
  5298.      */
  5299.     public function getFreezedAt()
  5300.     {
  5301.         return $this->freezedAt;
  5302.     }
  5303.     /**
  5304.      * Set freezedAt date.
  5305.      *
  5306.      * @return Listing
  5307.      */
  5308.     public function setFreezedAt($freezedAt)
  5309.     {
  5310.         $this->freezedAt $freezedAt;
  5311.         return $this;
  5312.     }
  5313.     public function getEligibleForBumpUp(): bool
  5314.     {
  5315.         return $this->eligibleForBumpUp;
  5316.     }
  5317.     public function setEligibleForBumpUp(bool $eligibleForBumpUp): self
  5318.     {
  5319.         $this->eligibleForBumpUp $eligibleForBumpUp;
  5320.         return $this;
  5321.     }
  5322.     /**
  5323.      * Get waiting time.
  5324.      *
  5325.      * @return string
  5326.      */
  5327.     public function getWaitingTime()
  5328.     {
  5329.         return $this->waitingTime;
  5330.     }
  5331.     /**
  5332.      * Set waiting time.
  5333.      *
  5334.      * @param string $waitingTime
  5335.      *
  5336.      * @return Listing
  5337.      */
  5338.     public function setWaitingTime($waitingTime)
  5339.     {
  5340.         $this->waitingTime $waitingTime;
  5341.         return $this;
  5342.     }
  5343.     /**
  5344.      * Get reference number.
  5345.      */
  5346.     public function getReferenceNumber(): ?string
  5347.     {
  5348.         return $this->referenceNumber;
  5349.     }
  5350.     /**
  5351.      * Set reference number.
  5352.      *
  5353.      * @param string $referenceNumber
  5354.      */
  5355.     public function setReferenceNumber($referenceNumber): self
  5356.     {
  5357.         $this->referenceNumber $referenceNumber;
  5358.         return $this;
  5359.     }
  5360.     public function getBrochure(): ?File
  5361.     {
  5362.         return $this->brochure;
  5363.     }
  5364.     public function setBrochure(?File $file): self
  5365.     {
  5366.         $this->brochure $file;
  5367.         return $this;
  5368.     }
  5369. }