src/Entity/User.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. /**
  11.  * @ORM\Entity(repositoryClass=UserRepository::class)
  12.  * @ORM\HasLifecycleCallbacks()
  13.  * @Vich\Uploadable
  14.  */
  15. class User implements UserInterface\Serializable
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $firstName;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      */
  30.     private $lastName;
  31.     /**
  32.      * @ORM\Column(type="string", length=180, unique=true)
  33.      */
  34.     private $email;
  35.     /**
  36.      * @ORM\Column(type="json", nullable=true)
  37.      */
  38.     private $roles = [];
  39.     /**
  40.      * @var string The hashed password
  41.      * @ORM\Column(type="string")
  42.      */
  43.     private $password;
  44.     /**
  45.      * @ORM\ManyToOne(targetEntity=Profile::class, inversedBy="UserId")
  46.      * @ORM\JoinColumn(nullable=false)
  47.      */
  48.     private $profile;
  49.     /**
  50.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  51.      *
  52.      * @Vich\UploadableField(mapping="user_image", fileNameProperty="image")
  53.      *
  54.      * @var File|null
  55.      */
  56.     private $imageFile;
  57.     /**
  58.      * @ORM\Column(type="string", length=255, nullable=true)
  59.      */
  60.     private $image;
  61.     /**
  62.      * @ORM\Column(type="datetime")
  63.      */
  64.     private $createdAt;
  65.     /**
  66.      * @ORM\Column(type="datetime", nullable=true)
  67.      */
  68.     private $updatedAt;
  69.     /**
  70.      * @ORM\OneToMany(targetEntity=CarBuy::class, mappedBy="user")
  71.      */
  72.     private $carBuyId;
  73.     /**
  74.      * @ORM\OneToMany(targetEntity=CarSale::class, mappedBy="user")
  75.      */
  76.     private $CarSaleId;
  77.     /**
  78.      * @ORM\OneToMany(targetEntity=Client::class, mappedBy="user")
  79.      */
  80.     private $client;
  81.     /**
  82.      * @ORM\Column(type="integer", nullable=true)
  83.      */
  84.     private $agencyDaysNotification;
  85.     /**
  86.      * @ORM\OneToMany(targetEntity=CarResale::class, mappedBy="user")
  87.      */
  88.     private $carResales;
  89.     /**
  90.      * @ORM\Column(type="boolean", nullable=true)
  91.      */
  92.     private $AllowUser;
  93.     /**
  94.      * @ORM\Column(type="boolean", nullable=true)
  95.      */
  96.     private $allowClients;
  97.     /**
  98.      * @ORM\Column(type="boolean", nullable=true)
  99.      */
  100.     private $allowVehicles;
  101.     /**
  102.      * @ORM\Column(type="boolean", nullable=true)
  103.      */
  104.     private $allowVehiclesBuys;
  105.     /**
  106.      * @ORM\Column(type="boolean", nullable=true)
  107.      */
  108.     private $allowVehiclesSales;
  109.     /**
  110.      * @ORM\Column(type="boolean", nullable=true)
  111.      */
  112.     private $allowVehiclesResales;
  113.     /**
  114.      * @ORM\Column(type="boolean", nullable=true)
  115.      */
  116.     private $allowAgency;
  117.     /**
  118.      * @ORM\Column(type="boolean", nullable=true)
  119.      */
  120.     private $allowAdministration;
  121.     /**
  122.      * @ORM\Column(type="boolean", nullable=true)
  123.      */
  124.     private $allowTransfers;
  125.     /**
  126.      * @ORM\Column(type="boolean", nullable=true)
  127.      */
  128.     private $allowSystem;
  129.     /**
  130.      * @ORM\Column(type="string", length=255, nullable=true)
  131.      */
  132.     private $cellphone;
  133.     public function __construct()
  134.     {
  135.         $this->carBuyId = new ArrayCollection();
  136.         $this->CarSaleId = new ArrayCollection();
  137.         $this->client = new ArrayCollection();
  138.         $this->carResales = new ArrayCollection();
  139.     }
  140.     public function getId(): ?int
  141.     {
  142.         return $this->id;
  143.     }
  144.     public function getFirstName(): ?string
  145.     {
  146.         return $this->firstName;
  147.     }
  148.     public function setFirstName(string $firstName): self
  149.     {
  150.         $this->firstName $firstName;
  151.         return $this;
  152.     }
  153.     public function getLastName(): ?string
  154.     {
  155.         return $this->lastName;
  156.     }
  157.     public function setLastName(string $lastName): self
  158.     {
  159.         $this->lastName $lastName;
  160.         return $this;
  161.     }
  162.     public function getEmail(): ?string
  163.     {
  164.         return $this->email;
  165.     }
  166.     public function setEmail(string $email): self
  167.     {
  168.         $this->email $email;
  169.         return $this;
  170.     }
  171.     /**
  172.      * A visual identifier that represents this user.
  173.      *
  174.      * @see UserInterface
  175.      */
  176.     public function getUsername(): string
  177.     {
  178.         return (string) $this->email;
  179.     }
  180.     /**
  181.      * @see UserInterface
  182.      */
  183.     public function getRoles(): array
  184.     {
  185.         $roles $this->roles;
  186.         // guarantee every user at least has ROLE_USER
  187.         //$roles[] = 'ROLE_USER';
  188.         return array_unique($roles);
  189.     }
  190.     public function setRoles(array $roles): self
  191.     {
  192.         $this->roles $roles;
  193.         return $this;
  194.     }
  195.     /**
  196.      * @see UserInterface
  197.      */
  198.     public function getPassword(): ?string
  199.     {
  200.         return $this->password;
  201.     }
  202.     public function setPassword(?string $password): self
  203.     {
  204.         $this->password $password;
  205.         return $this;
  206.     }
  207.     /**
  208.      * Returning a salt is only needed, if you are not using a modern
  209.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  210.      *
  211.      * @see UserInterface
  212.      */
  213.     public function getSalt(): ?string
  214.     {
  215.         return null;
  216.     }
  217.     /**
  218.      * @see UserInterface
  219.      */
  220.     public function eraseCredentials()
  221.     {
  222.         // If you store any temporary, sensitive data on the user, clear it here
  223.         // $this->plainPassword = null;
  224.     }
  225.     public function getProfile(): ?Profile
  226.     {
  227.         return $this->profile;
  228.     }
  229.     public function setProfile(?Profile $profile): self
  230.     {
  231.         $this->profile $profile;
  232.         return $this;
  233.     }
  234.     /**
  235.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  236.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  237.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  238.      * must be able to accept an instance of 'File' as the bundle will inject one here
  239.      * during Doctrine hydration.
  240.      *
  241.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  242.      */
  243.     public function setImageFile(?File $imageFile null): void
  244.     {
  245.         $this->imageFile $imageFile;
  246.         if (null !== $imageFile) {
  247.             // It is required that at least one field changes if you are using doctrine
  248.             // otherwise the event listeners won't be called and the file is lost
  249.             $this->updatedAt = new \DateTimeImmutable();
  250.         }
  251.     }
  252.     public function getImageFile(): ?File
  253.     {
  254.         return $this->imageFile;
  255.     }
  256.     public function getImage(): ?string
  257.     {
  258.         return $this->image;
  259.     }
  260.     public function setImage(?string $image): self
  261.     {
  262.         $this->image $image;
  263.         return $this;
  264.     }
  265.     public function getCreatedAt(): ?\DateTime
  266.     {
  267.         return $this->createdAt;
  268.     }
  269.     /**
  270.      * @ORM\PrePersist
  271.      */
  272.     //public function setCreatedAt(\DateTime $createdAt): self
  273.     public function setCreatedAt(): self
  274.     {
  275.         $this->createdAt = new \DateTime();
  276.         return $this;
  277.     }
  278.     public function getUpdatedAt(): ?\DateTime
  279.     {
  280.         return $this->updatedAt;
  281.     }
  282.     /**
  283.      * @ORM\PreUpdate
  284.      */
  285.     public function setUpdatedAt(): self
  286.     {
  287.         $this->updatedAt = new \DateTime();
  288.         return $this;
  289.     }
  290.     public function serialize()
  291.     {
  292.         return serialize(array(
  293.             $this->id,
  294.             $this->email,
  295.             $this->password,
  296.         ));
  297.     }
  298.     public function unserialize($serialized)
  299.     {
  300.         list(
  301.             $this->id,
  302.             $this->email,
  303.             $this->password,
  304.             ) = unserialize($serialized);
  305.     }
  306.     /**
  307.      * @return Collection|CarBuy[]
  308.      */
  309.     public function getCarBuyId(): Collection
  310.     {
  311.         return $this->carBuyId;
  312.     }
  313.     public function addCarBuyId(CarBuy $carBuyId): self
  314.     {
  315.         if (!$this->carBuyId->contains($carBuyId)) {
  316.             $this->carBuyId[] = $carBuyId;
  317.             $carBuyId->setUser($this);
  318.         }
  319.         return $this;
  320.     }
  321.     public function removecarBuyId(CarBuy $carBuyId): self
  322.     {
  323.         if ($this->carBuyId->removeElement($carBuyId)) {
  324.             // set the owning side to null (unless already changed)
  325.             if ($carBuyId->getUser() === $this) {
  326.                 $carBuyId->setUser(null);
  327.             }
  328.         }
  329.         return $this;
  330.     }
  331.     /**
  332.      * @return Collection|CarSale[]
  333.      */
  334.     public function getCarSaleId(): Collection
  335.     {
  336.         return $this->CarSaleId;
  337.     }
  338.     public function addCarSaleId(CarSale $carSaleId): self
  339.     {
  340.         if (!$this->CarSaleId->contains($carSaleId)) {
  341.             $this->CarSaleId[] = $carSaleId;
  342.             $carSaleId->setUser($this);
  343.         }
  344.         return $this;
  345.     }
  346.     public function removeCarSaleId(CarSale $carSaleId): self
  347.     {
  348.         if ($this->CarSaleId->removeElement($carSaleId)) {
  349.             // set the owning side to null (unless already changed)
  350.             if ($carSaleId->getUser() === $this) {
  351.                 $carSaleId->setUser(null);
  352.             }
  353.         }
  354.         return $this;
  355.     }
  356.     /**
  357.      * @return Collection|Client[]
  358.      */
  359.     public function getClient(): Collection
  360.     {
  361.         return $this->client;
  362.     }
  363.     public function addClient(Client $client): self
  364.     {
  365.         if (!$this->client->contains($client)) {
  366.             $this->client[] = $client;
  367.             $client->setUser($this);
  368.         }
  369.         return $this;
  370.     }
  371.     public function removeClient(Client $client): self
  372.     {
  373.         if ($this->client->removeElement($client)) {
  374.             // set the owning side to null (unless already changed)
  375.             if ($client->getUser() === $this) {
  376.                 $client->setUser(null);
  377.             }
  378.         }
  379.         return $this;
  380.     }
  381.     public function getAgencyDaysNotification(): ?int
  382.     {
  383.         return $this->agencyDaysNotification;
  384.     }
  385.     public function setAgencyDaysNotification(?int $agencyDaysNotification): self
  386.     {
  387.         $this->agencyDaysNotification $agencyDaysNotification;
  388.         return $this;
  389.     }
  390.     /**
  391.      * @return Collection<int, CarResale>
  392.      */
  393.     public function getCarResales(): Collection
  394.     {
  395.         return $this->carResales;
  396.     }
  397.     public function addCarResale(CarResale $carResale): self
  398.     {
  399.         if (!$this->carResales->contains($carResale)) {
  400.             $this->carResales[] = $carResale;
  401.             $carResale->setUser($this);
  402.         }
  403.         return $this;
  404.     }
  405.     public function removeCarResale(CarResale $carResale): self
  406.     {
  407.         if ($this->carResales->removeElement($carResale)) {
  408.             // set the owning side to null (unless already changed)
  409.             if ($carResale->getUser() === $this) {
  410.                 $carResale->setUser(null);
  411.             }
  412.         }
  413.         return $this;
  414.     }
  415.     public function getAllowUser(): ?bool
  416.     {
  417.         return $this->AllowUser;
  418.     }
  419.     public function setAllowUser(?bool $AllowUser): self
  420.     {
  421.         $this->AllowUser $AllowUser;
  422.         return $this;
  423.     }
  424.     public function getAllowClients(): ?bool
  425.     {
  426.         return $this->allowClients;
  427.     }
  428.     public function setAllowClients(?bool $allowClients): self
  429.     {
  430.         $this->allowClients $allowClients;
  431.         return $this;
  432.     }
  433.     public function getAllowVehicles(): ?bool
  434.     {
  435.         return $this->allowVehicles;
  436.     }
  437.     public function setAllowVehicles(?bool $allowVehicles): self
  438.     {
  439.         $this->allowVehicles $allowVehicles;
  440.         return $this;
  441.     }
  442.     public function getAllowVehiclesBuys(): ?bool
  443.     {
  444.         return $this->allowVehiclesBuys;
  445.     }
  446.     public function setAllowVehiclesBuys(?bool $allowVehiclesBuys): self
  447.     {
  448.         $this->allowVehiclesBuys $allowVehiclesBuys;
  449.         return $this;
  450.     }
  451.     public function getAllowVehiclesSales(): ?bool
  452.     {
  453.         return $this->allowVehiclesSales;
  454.     }
  455.     public function setAllowVehiclesSales(?bool $allowVehiclesSales): self
  456.     {
  457.         $this->allowVehiclesSales $allowVehiclesSales;
  458.         return $this;
  459.     }
  460.     public function getAllowVehiclesResales(): ?bool
  461.     {
  462.         return $this->allowVehiclesResales;
  463.     }
  464.     public function setAllowVehiclesResales(?bool $allowVehiclesResales): self
  465.     {
  466.         $this->allowVehiclesResales $allowVehiclesResales;
  467.         return $this;
  468.     }
  469.     public function getAllowAgency(): ?bool
  470.     {
  471.         return $this->allowAgency;
  472.     }
  473.     public function setAllowAgency(?bool $allowAgency): self
  474.     {
  475.         $this->allowAgency $allowAgency;
  476.         return $this;
  477.     }
  478.     public function getAllowAdministration(): ?bool
  479.     {
  480.         return $this->allowAdministration;
  481.     }
  482.     public function setAllowAdministration(?bool $allowAdministration): self
  483.     {
  484.         $this->allowAdministration $allowAdministration;
  485.         return $this;
  486.     }
  487.     public function getAllowTransfers(): ?bool
  488.     {
  489.         return $this->allowTransfers;
  490.     }
  491.     public function setAllowTransfers(?bool $allowTransfers): self
  492.     {
  493.         $this->allowTransfers $allowTransfers;
  494.         return $this;
  495.     }
  496.     public function getAllowSystem(): ?bool
  497.     {
  498.         return $this->allowSystem;
  499.     }
  500.     public function setAllowSystem(?bool $allowSystem): self
  501.     {
  502.         $this->allowSystem $allowSystem;
  503.         return $this;
  504.     }
  505.     public function getCellphone(): ?string
  506.     {
  507.         return $this->cellphone;
  508.     }
  509.     public function setCellphone(?string $cellphone): self
  510.     {
  511.         $this->cellphone $cellphone;
  512.         return $this;
  513.     }
  514. }