src/Entity/Account/Advertiser.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Account;
  3. use App\Entity\Saloon\Saloon;
  4. use App\Entity\Profile\Profile;
  5. use App\Entity\User;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Doctrine\ORM\PersistentCollection;
  10. #[ORM\Entity]
  11. class Advertiser extends User
  12. {
  13.     public const ROLE_ADVERTISER 'ROLE_ADVERTISER';
  14.     #[ORM\OneToMany(targetEntityPhoneReviewAdded::class, mappedBy'user'cascade: ['all'])]
  15.     private Collection $phoneReviewsAdded;
  16.     /** @var Profile[] */
  17.     #[ORM\OneToMany(targetEntityProfile::class, mappedBy'owner')]
  18.     private Collection $profiles;
  19.     /** @var Saloon[] */
  20.     #[ORM\OneToMany(targetEntitySaloon::class, mappedBy'owner')]
  21.     private Collection $saloons;
  22.     public function __construct()
  23.     {
  24.         parent::__construct();
  25.         $this->profiles = new ArrayCollection();
  26.         $this->saloons = new ArrayCollection();
  27.         $this->phoneReviewsAdded = new ArrayCollection();
  28.         $this->setRoles(array_merge($this->getRoles(), [self::ROLE_ADVERTISER]));
  29.     }
  30.     public function getProfiles(): Collection
  31.     {
  32.         return $this->profiles;
  33.     }
  34.     public function addProfile(Profile $profile): void
  35.     {
  36.         if (!$this->profiles->contains($profile)) {
  37.             $this->profiles->add($profile);
  38.         }
  39.     }
  40.     public function removeProfile(Profile $profile): void
  41.     {
  42.         $this->profiles->removeElement($profile);
  43.     }
  44.     /**
  45.      * @return Saloon[]
  46.      */
  47.     public function getSaloons(): Collection
  48.     {
  49.         return $this->saloons;
  50.     }
  51.     public function addSaloon(Saloon $saloon): void
  52.     {
  53.         if (!$this->saloons->contains($saloon)) {
  54.             $this->saloons->add($saloon);
  55.         }
  56.     }
  57.     public function removeSaloon(Saloon $saloon): void
  58.     {
  59.         $this->saloons->removeElement($saloon);
  60.     }
  61.     public function getPhoneReviewsAdded(): Collection
  62.     {
  63.         return $this->phoneReviewsAdded;
  64.     }
  65.     public function __toString(): string
  66.     {
  67.         return (string)$this->getId();
  68.     }
  69. }