<?php
namespace App\Entity;
use App\Entity\Model\UserModel;
use App\Entity\ReseauSociaux\Conversation;
use App\Entity\ReseauSociaux\Espace;
use App\Entity\ReseauSociaux\Message;
use App\Entity\ReseauSociaux\Notifications;
use App\Entity\ReseauSociaux\PostLike;
use App\Entity\ReseauSociaux\Publication;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\CompanyRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=CompanyRepository::class)
* @UniqueEntity(fields={"email"}, message="Cette adresse mail est déjà utilisée")
* @UniqueEntity(fields={"companyName"}, message="Ce nom d'entreprise est déjà utilisé")
*/
class Company extends UserModel implements UserInterface
{
const COMPANY_TYPE_SERVICE = 'service';
const COMPANY_TYPE_PRODUCT = 'product';
const COMPANY_TYPE_ENTREPRISE = "entreprise";
const COMPANY_TYPE_INDIVIDUEL = "particulier";
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
* @Groups("post:read","show:read", "connect:read", "publication:read", "message:read", "notif:read")
*/
private $id;
/**
* @ORM\Column(type="string", length=191)
*/
private $siren;
/**
* @ORM\Column(type="string", length=191, nullable=true)
* @Groups("show:read", "notif:read")
*/
private $contactName;
/**
* @ORM\Column(type="string", length=191, nullable=true)
* @Groups("show:read")
*/
private $contactPhone;
/**
* @ORM\Column(type="string", length=191, unique=true, nullable=true)
* @Groups("show:read","post:read", "publication:read", "notif:read")
*/
private $companyName;
/**
* @ORM\Column(type="string", length=191, nullable=true)
*/
private $fax;
/**
* @ORM\Column(type="string", length=191, nullable=true)
*
* @Assert\Url(message="L'URL renseignée n'est pas valide")
*/
private $website;
/**
* @ORM\Column(type="string", length=191, nullable=true)
*/
private $contactCivility;
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @Assert\IsTrue(message="Pour poursuivre votre inscription, vous devez accepter les conditions générales de Hobbiinn")
*/
private $isAcceptCondition;
/**
* @ORM\OneToMany(targetEntity=Product::class, mappedBy="company")
*/
private $products;
/**
* @ORM\Column(type="string", length=191)
* @Groups("post:read", "publication:read")
*/
private $companySlug;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=191, nullable=true)
* @Groups("post:read","connect:read","show:read","publication:read", "notif:read")
*/
private $image;
/**
* @ORM\OneToMany(targetEntity=Messaging::class, mappedBy="messageCompany")
*/
private $messagings;
/**
* @ORM\Column(type="boolean")
*/
private $isConfirmed;
/**
* @ORM\OneToMany(targetEntity=PlanningCompany::class, mappedBy="company", orphanRemoval=true)
*/
private $planningCompanies;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $kbis;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $conditionsVente;
/**
* @ORM\ManyToMany(targetEntity=Category::class, inversedBy="companies")
* @Assert\NotBlank(message="Veuillez sélectionner votre secteur d’activité")
*/
private $category;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $stripId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $stripeAccount;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups("post:read","connect:read","show:read", "publication:read", "message:read", "notif:read")
*/
private $firstName;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $contactBirthday;
/**
* @ORM\Column(type="string", length=4, nullable=true)
*/
private $country;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $mangoId;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isValidDocument;
/**
* @ORM\OneToMany(targetEntity=Payout::class, mappedBy="company")
*/
private $payouts;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $type;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isEditorGuide;
/**
* @ORM\OneToMany(targetEntity=Abonnement::class, mappedBy="company", cascade={"persist", "remove"})
*/
private $abonnements;
/**
* @ORM\OneToMany(targetEntity=AnnonceCompany::class, mappedBy="companys")
*/
private $annonceCompanies;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $paiementActiv;
/**
* @ORM\OneToMany(targetEntity=Notification::class, mappedBy="company")
*/
private $notifications;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $commissionActive;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups("post:read","connect:read","show:read")
*/
private $statuCon;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups("post:read","connect:read")
*/
private $etatNetwork;
/**
* @ORM\OneToMany(targetEntity=Publication::class, mappedBy="company")
*/
private $publications;
/**
* @ORM\OneToMany(targetEntity=Conversation::class, mappedBy="utilisateurComp1")
*/
private $conversations;
/**
* @ORM\OneToMany(targetEntity=Message::class, mappedBy="senderComp")
*/
private $messages;
/**
* @ORM\OneToMany(targetEntity=Publication::class, mappedBy="company_publier")
*/
private $pub_company;
/**
* @ORM\OneToMany(targetEntity=Espace::class, mappedBy="proprietairecomp")
* @Groups("post:read")
*/
private $espaces;
/**
* @ORM\ManyToMany(targetEntity=Espace::class, inversedBy="companies")
* @Groups("post:read")
*/
private $follow;
/**
* @ORM\OneToMany(targetEntity=Notifications::class, mappedBy="company")
*/
private $notificationsreseau;
/**
* @ORM\OneToMany(targetEntity=PostLike::class, mappedBy="company")
*/
private $likes;
/**
* @ORM\OneToMany(targetEntity=PendingLocation::class, mappedBy="company")
*/
private $pendingLocations;
/**
* @ORM\OneToMany(targetEntity=PendingReservation::class, mappedBy="company")
*/
private $pendingReservations;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdAt;
/**
* @ORM\Column(type="boolean")
*/
private $isDirectReservationMode;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $stripeId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $stripeAccountId;
/**
* @ORM\Column(type="json")
* @Groups({"show:read"})
*/
protected $roles = [];
/**
* @Groups({"show:read"})
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function __construct()
{
$this->products = new ArrayCollection();
$this->messagings = new ArrayCollection();
$this->isConfirmed = false;
$this->planningCompanies = new ArrayCollection();
$this->category = new ArrayCollection();
$this->payouts = new ArrayCollection();
$this->isEditorGuide = false;
$this->annonceCompanies = new ArrayCollection();
$this->notifications = new ArrayCollection();
$this->publications = new ArrayCollection();
$this->conversations = new ArrayCollection();
$this->messages = new ArrayCollection();
$this->pub_company = new ArrayCollection();
$this->espaces = new ArrayCollection();
$this->follow = new ArrayCollection();
$this->notificationsreseau = new ArrayCollection();
$this->likes = new ArrayCollection();
$this->pendingLocations = new ArrayCollection();
$this->abonnements = new ArrayCollection();
}
/**
* @Groups("show:read", "publication:read")
*/
public function getId(): ?int
{
return $this->id;
}
public function getSiren(): ?string
{
return $this->siren;
}
public function setSiren(string $siren): self
{
$this->siren = $siren;
return $this;
}
/**
* @Groups("show:read", "publication:read")
*/
public function getContactName(): ?string
{
return $this->contactName;
}
public function setContactName(string $contactName): self
{
$this->contactName = $contactName;
return $this;
}
public function getContactPhone(): ?string
{
return $this->contactPhone;
}
public function setContactPhone(?string $contactPhone): self
{
$this->contactPhone = $contactPhone;
return $this;
}
/**
* @Groups("show:read", "publication:read")
*/
public function getCompanyName(): ?string
{
return $this->companyName;
}
public function setCompanyName(string $companyName): self
{
$this->companyName = $companyName;
return $this;
}
public function getFax(): ?string
{
return $this->fax;
}
public function setFax(?string $fax): self
{
$this->fax = $fax;
return $this;
}
public function getWebsite(): ?string
{
return $this->website;
}
public function setWebsite(?string $website): self
{
$this->website = $website;
return $this;
}
public function getContactCivility(): ?string
{
return $this->contactCivility;
}
public function setContactCivility(string $contactCivility): self
{
$this->contactCivility = $contactCivility;
return $this;
}
public function getIsAcceptCondition(): ?bool
{
return $this->isAcceptCondition;
}
public function setIsAcceptCondition(?bool $isAcceptCondition): self
{
$this->isAcceptCondition = $isAcceptCondition;
return $this;
}
/**
* @return Collection|Product[]
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->setCompany($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->contains($product)) {
$this->products->removeElement($product);
// set the owning side to null (unless already changed)
if ($product->getCompany() === $this) {
$product->setCompany(null);
}
}
return $this;
}
public function getCompanySlug(): ?string
{
return $this->companySlug;
}
public function setCompanySlug(string $companySlug): self
{
$this->companySlug = $companySlug;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @Groups("show:read", "publication:read")
*/
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
/**
* @return Collection|Messaging[]
*/
public function getMessagings(): Collection
{
return $this->messagings;
}
public function addMessaging(Messaging $messaging): self
{
if (!$this->messagings->contains($messaging)) {
$this->messagings[] = $messaging;
$messaging->setMessageCompany($this);
}
return $this;
}
public function removeMessaging(Messaging $messaging): self
{
if ($this->messagings->contains($messaging)) {
$this->messagings->removeElement($messaging);
// set the owning side to null (unless already changed)
if ($messaging->getMessageCompany() === $this) {
$messaging->setMessageCompany(null);
}
}
return $this;
}
public function getIsConfirmed(): ?bool
{
return $this->isConfirmed;
}
public function setIsConfirmed(bool $isConfirmed): self
{
$this->isConfirmed = $isConfirmed;
return $this;
}
/**
* @return Collection|PlanningCompany[]
*/
public function getPlanningCompanies(): Collection
{
return $this->planningCompanies;
}
public function addPlanningCompany(PlanningCompany $planningCompany): self
{
if (!$this->planningCompanies->contains($planningCompany)) {
$this->planningCompanies[] = $planningCompany;
$planningCompany->setCompany($this);
}
return $this;
}
public function removePlanningCompany(PlanningCompany $planningCompany): self
{
if ($this->planningCompanies->contains($planningCompany)) {
$this->planningCompanies->removeElement($planningCompany);
// set the owning side to null (unless already changed)
if ($planningCompany->getCompany() === $this) {
$planningCompany->setCompany(null);
}
}
return $this;
}
public function getKbis()
{
return $this->kbis;
}
public function setKbis($kbis): self
{
$this->kbis = $kbis;
return $this;
}
public function getConditionsVente(): ?string
{
return $this->conditionsVente;
}
public function setConditionsVente(?string $conditionsVente): self
{
$this->conditionsVente = $conditionsVente;
return $this;
}
/**
* @return Collection|Category[]
*/
public function getCategory(): Collection
{
return $this->category;
}
public function addCategory(Category $category): self
{
if (!$this->category->contains($category)) {
$this->category[] = $category;
}
return $this;
}
public function removeCategory(Category $category): self
{
if ($this->category->contains($category)) {
$this->category->removeElement($category);
}
return $this;
}
public function getStripId(): ?string
{
return $this->stripId;
}
public function setStripId(?string $stripId): self
{
$this->stripId = $stripId;
return $this;
}
public function getStripeAccount(): ?string
{
return $this->stripeAccount;
}
public function setStripeAccount(?string $stripeAccount): self
{
$this->stripeAccount = $stripeAccount;
return $this;
}
/**
* @Groups("show:read", "publication:read")
*/
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getContactBirthday(): ?\DateTimeInterface
{
return $this->contactBirthday;
}
public function setContactBirthday(?\DateTimeInterface $contactBirthday): self
{
$this->contactBirthday = $contactBirthday;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
public function getMangoId(): ?string
{
return $this->mangoId;
}
public function setMangoId(?string $mangoId): self
{
$this->mangoId = $mangoId;
return $this;
}
public function getIsValidDocument(): ?bool
{
return $this->isValidDocument;
}
public function setIsValidDocument(?bool $isValidDocument): self
{
$this->isValidDocument = $isValidDocument;
return $this;
}
/**
* @return Collection|Payout[]
*/
public function getPayouts(): Collection
{
return $this->payouts;
}
public function addPayout(Payout $payout): self
{
if (!$this->payouts->contains($payout)) {
$this->payouts[] = $payout;
$payout->setCompany($this);
}
return $this;
}
public function removePayout(Payout $payout): self
{
if ($this->payouts->removeElement($payout)) {
// set the owning side to null (unless already changed)
if ($payout->getCompany() === $this) {
$payout->setCompany(null);
}
}
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getIsEditorGuide(): ?bool
{
return $this->isEditorGuide;
}
public function setIsEditorGuide(?bool $isEditorGuide): self
{
$this->isEditorGuide = $isEditorGuide;
return $this;
}
public function getAbonnements(): ?Collection
{
return $this->abonnements;
}
public function addAbbonnement(Abonnement $abonnement): self
{
if (!$this->abonnements->contains($abonnement)) {
$this->abonnements[] = $abonnement;
$abonnement->setCompany($this);
}
return $this;
}
// public function removeAbbonnement(Abonnement $abonnement): self
// {
// if ($this->abonnements->removeElement($abonnement)) {
// // set the owning side to null (unless already changed)
// if ($abonnement->getCompany() === $this) {
// $abonnement->setCompany(null);
// }
// }
// return $this;
// }
/**
* @return Collection|AnnonceCompany[]
*/
public function getAnnonceCompanies(): Collection
{
return $this->annonceCompanies;
}
public function addAnnonceCompany(AnnonceCompany $annonceCompany): self
{
if (!$this->annonceCompanies->contains($annonceCompany)) {
$this->annonceCompanies[] = $annonceCompany;
$annonceCompany->setCompanys($this);
}
return $this;
}
public function removeAnnonceCompany(AnnonceCompany $annonceCompany): self
{
if ($this->annonceCompanies->removeElement($annonceCompany)) {
// set the owning side to null (unless already changed)
if ($annonceCompany->getCompanys() === $this) {
$annonceCompany->setCompanys(null);
}
}
return $this;
}
public function getPaiementActiv(): ?bool
{
return $this->paiementActiv;
}
public function setPaiementActiv(?bool $paiementActiv): self
{
$this->paiementActiv = $paiementActiv;
return $this;
}
/**
* @return Collection|Notification[]
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setCompany($this);
}
return $this;
}
public function removeNotification(Notification $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getCompany() === $this) {
$notification->setCompany(null);
}
}
return $this;
}
public function getCommissionActive(): ?bool
{
return $this->commissionActive;
}
public function setCommissionActive(?bool $commissionActive): self
{
$this->commissionActive = $commissionActive;
return $this;
}
public function getStatuCon(): ?bool
{
return $this->statuCon;
}
public function setStatuCon(?bool $statuCon): self
{
$this->statuCon = $statuCon;
return $this;
}
public function getEtatNetwork(): ?\DateTimeInterface
{
return $this->etatNetwork;
}
public function setEtatNetwork(\DateTimeInterface $etatNetwork): self
{
$this->etatNetwork = $etatNetwork;
return $this;
}
public function __toString()
{
return $this->getFirstName();
}
/**
* @return Collection<int, Publication>
*/
public function getPublications(): Collection
{
return $this->publications;
}
public function addPublication(Publication $publication): self
{
if (!$this->publications->contains($publication)) {
$this->publications[] = $publication;
$publication->setCompany($this);
}
return $this;
}
public function removePublication(Publication $publication): self
{
if ($this->publications->removeElement($publication)) {
// set the owning side to null (unless already changed)
if ($publication->getCompany() === $this) {
$publication->setCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, Conversation>
*/
public function getConversations(): Collection
{
return $this->conversations;
}
public function addConversation(Conversation $conversation): self
{
if (!$this->conversations->contains($conversation)) {
$this->conversations[] = $conversation;
$conversation->setUtilisateurComp1($this);
}
return $this;
}
public function removeConversation(Conversation $conversation): self
{
if ($this->conversations->removeElement($conversation)) {
// set the owning side to null (unless already changed)
if ($conversation->getUtilisateurComp1() === $this) {
$conversation->setUtilisateurComp1(null);
}
}
return $this;
}
/**
* @return Collection<int, Message>
*/
public function getMessages(): Collection
{
return $this->messages;
}
public function addMessage(Message $message): self
{
if (!$this->messages->contains($message)) {
$this->messages[] = $message;
$message->setSenderComp($this);
}
return $this;
}
public function removeMessage(Message $message): self
{
if ($this->messages->removeElement($message)) {
// set the owning side to null (unless already changed)
if ($message->getSenderComp() === $this) {
$message->setSenderComp(null);
}
}
return $this;
}
/**
* @return Collection<int, Publication>
*/
public function getPubCompany(): Collection
{
return $this->pub_company;
}
public function addPubCompany(Publication $pubCompany): self
{
if (!$this->pub_company->contains($pubCompany)) {
$this->pub_company[] = $pubCompany;
$pubCompany->setCompanyPublier($this);
}
return $this;
}
public function removePubCompany(Publication $pubCompany): self
{
if ($this->pub_company->removeElement($pubCompany)) {
// set the owning side to null (unless already changed)
if ($pubCompany->getCompanyPublier() === $this) {
$pubCompany->setCompanyPublier(null);
}
}
return $this;
}
/**
* @return Collection<int, Espace>
*/
public function getEspaces(): Collection
{
return $this->espaces;
}
public function addEspace(Espace $espace): self
{
if (!$this->espaces->contains($espace)) {
$this->espaces[] = $espace;
$espace->setProprietairecomp($this);
}
return $this;
}
public function removeEspace(Espace $espace): self
{
if ($this->espaces->removeElement($espace)) {
// set the owning side to null (unless already changed)
if ($espace->getProprietairecomp() === $this) {
$espace->setProprietairecomp(null);
}
}
return $this;
}
/**
* @return Collection<int, Espace>
*/
public function getFollow(): Collection
{
return $this->follow;
}
public function addFollow(Espace $follow): self
{
if (!$this->follow->contains($follow)) {
$this->follow[] = $follow;
}
return $this;
}
public function removeFollow(Espace $follow): self
{
$this->follow->removeElement($follow);
return $this;
}
/**
* @return Collection<int, Notifications>
*/
public function getNotificationsreseau(): Collection
{
return $this->notificationsreseau;
}
public function addNotificationsreseau(Notifications $notificationsreseau): self
{
if (!$this->notificationsreseau->contains($notificationsreseau)) {
$this->notificationsreseau[] = $notificationsreseau;
$notificationsreseau->setCompany($this);
}
return $this;
}
public function removeNotificationsreseau(Notifications $notificationsreseau): self
{
if ($this->notificationsreseau->removeElement($notificationsreseau)) {
// set the owning side to null (unless already changed)
if ($notificationsreseau->getCompany() === $this) {
$notificationsreseau->setCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, PendingLocation>
*/
public function getPendingLocations(): Collection
{
return $this->pendingLocations;
}
public function addPendingLocation(PendingLocation $pendingLocation): self
{
if (!$this->pendingLocations->contains($pendingLocation)) {
$this->pendingLocations[] = $pendingLocation;
$pendingLocation->setCompany($this);
}
return $this;
}
public function removePendingLocation(PendingLocation $pendingLocation): void
{
if ($this->pendingLocations->removeElement($pendingLocation)) {
// set the owning side to null (unless already changed)
if ($pendingLocation->getCompany() === $this) {
$pendingLocation->setCompany(null);
}
}
}
/**
* @return Collection<int, PostLike>
*/
public function getLikes(): Collection
{
return $this->likes;
}
public function addLike(PostLike $like): self
{
if (!$this->likes->contains($like)) {
$this->likes[] = $like;
$like->setCompany($this);
}
return $this;
}
public function removeLike(PostLike $like): self
{
if ($this->likes->removeElement($like)) {
// set the owning side to null (unless already changed)
if ($like->getCompany() === $this) {
$like->setCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, PendingReservation>
*/
public function getPendingReservations(): Collection
{
return $this->pendingReservations;
}
public function addPendingReservation(PendingReservation $pendingReservation): self
{
if (!$this->pendingReservations->contains($pendingReservation)) {
$this->pendingReservations[] = $pendingReservation;
$pendingReservation->setCompany($this);
}
return $this;
}
public function removePendingReservation(PendingReservation $pendingReservation): self
{
if ($this->pendingReservations->removeElement($pendingReservation)) {
// set the owning side to null (unless already changed)
if ($pendingReservation->getCompany() === $this) {
$pendingReservation->setCompany(null);
}
}
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getIsDirectReservationMode(): ?bool
{
return $this->isDirectReservationMode;
}
public function setIsDirectReservationMode(bool $isDirectReservationMode): self
{
$this->isDirectReservationMode = $isDirectReservationMode;
return $this;
}
public function getStripeId(): ?string
{
return $this->stripeId;
}
public function setStripeId(?string $stripeId): self
{
$this->stripeId = $stripeId;
return $this;
}
public function getStripeAccountId(): ?string
{
return $this->stripeAccountId;
}
public function setStripeAccountId(?string $stripeAccountId): self
{
$this->stripeAccountId = $stripeAccountId;
return $this;
}
}