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

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