src/Entity/User.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Auditable;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use FOS\UserBundle\Model\User as BaseUser;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  10.  * @ORM\Table(name="fos_user")
  11.  */
  12. class User extends BaseUser
  13. {
  14.     use Auditable;
  15.     /**
  16.      * @ORM\Id()
  17.      * @ORM\GeneratedValue()
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     protected $id;
  21.     /**
  22.      * @ORM\ManyToOne(targetEntity="App\Entity\OrganizationUnit", inversedBy="users")
  23.      */
  24.     protected $organizationUnit;
  25.     /**
  26.      * @ORM\Column(type="string", nullable=true)
  27.      */
  28.     protected $firstName;
  29.     /**
  30.      * @ORM\Column(type="string", nullable=true)
  31.      */
  32.     protected $lastName;
  33.     /**
  34.      * @ORM\Column(type="string", nullable=true)
  35.      */
  36.     protected $telephone;
  37.     /**
  38.      * @ORM\Column(type="text", nullable=true)
  39.      */
  40.     protected $additionalNotes;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity="App\Entity\Booking", mappedBy="user")
  43.      */
  44.     private $bookings;
  45.     /**
  46.      * @ORM\Column(type="string", length=64)
  47.      */
  48.     private $settingTimeZone 'Europe/London';
  49.     public function __construct()
  50.     {
  51.         parent::__construct();
  52.         $this->bookings = new ArrayCollection();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getOrganizationUnit(): ?OrganizationUnit
  59.     {
  60.         return $this->organizationUnit;
  61.     }
  62.     public function setOrganizationUnit(?OrganizationUnit $organizationUnit): self
  63.     {
  64.         $this->organizationUnit $organizationUnit;
  65.         return $this;
  66.     }
  67.     /**
  68.      * @return mixed
  69.      */
  70.     public function getAdditionalNotes()
  71.     {
  72.         return $this->additionalNotes;
  73.     }
  74.     /**
  75.      * @param mixed $additionalNotes
  76.      * @return User
  77.      */
  78.     public function setAdditionalNotes($additionalNotes)
  79.     {
  80.         $this->additionalNotes $additionalNotes;
  81.         return $this;
  82.     }
  83.     /**
  84.      * @return mixed
  85.      */
  86.     public function getFirstName()
  87.     {
  88.         return $this->firstName;
  89.     }
  90.     /**
  91.      * @param mixed $firstName
  92.      * @return User
  93.      */
  94.     public function setFirstName($firstName)
  95.     {
  96.         $this->firstName $firstName;
  97.         return $this;
  98.     }
  99.     /**
  100.      * @return mixed
  101.      */
  102.     public function getLastName()
  103.     {
  104.         return $this->lastName;
  105.     }
  106.     /**
  107.      * @param mixed $lastName
  108.      * @return User
  109.      */
  110.     public function setLastName($lastName)
  111.     {
  112.         $this->lastName $lastName;
  113.         return $this;
  114.     }
  115.     /**
  116.      * @return mixed
  117.      */
  118.     public function getTelephone()
  119.     {
  120.         return $this->telephone;
  121.     }
  122.     /**
  123.      * @param mixed $telephone
  124.      * @return User
  125.      */
  126.     public function setTelephone($telephone)
  127.     {
  128.         $this->telephone $telephone;
  129.         return $this;
  130.     }
  131.     /**
  132.      * @return mixed
  133.      */
  134.     public function getFullName()
  135.     {
  136.         return trim($this->firstName ' ' $this->lastName);
  137.     }
  138.     /**
  139.      * @return mixed
  140.      */
  141.     public function getDisplayName()
  142.     {
  143.         $name $this->getFullName();
  144.         if (empty($name)) {
  145.             $name=$this->username;
  146.         }
  147.         return $name;
  148.     }
  149.     /**
  150.      * @return Collection|Booking[]
  151.      */
  152.     public function getBookings(): Collection
  153.     {
  154.         return $this->bookings;
  155.     }
  156.     public function addBooking(Booking $booking): self
  157.     {
  158.         if (!$this->bookings->contains($booking)) {
  159.             $this->bookings[] = $booking;
  160.             $booking->setUser($this);
  161.         }
  162.         return $this;
  163.     }
  164.     public function removeBooking(Booking $booking): self
  165.     {
  166.         if ($this->bookings->contains($booking)) {
  167.             $this->bookings->removeElement($booking);
  168.             // set the owning side to null (unless already changed)
  169.             if ($booking->getUser() === $this) {
  170.                 $booking->setUser(null);
  171.             }
  172.         }
  173.         return $this;
  174.     }
  175.     public function getSettingTimeZone(): ?string
  176.     {
  177.         return $this->settingTimeZone;
  178.     }
  179.     public function setSettingTimeZone(string $settingTimeZone): self
  180.     {
  181.         $this->settingTimeZone $settingTimeZone;
  182.         return $this;
  183.     }
  184. }