/
vladislavts
/
gcppmsp
Обзор
Документация
Войти
/
vladislavts
/
gcppmsp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
prod
src/Entity/User.php
284 строки
6 KB
vladislav_ts@list.ru
Сздал УРЛ с удалением пользователей
08 сен 2024, 13:26
08 сен 2024, 13:26
c74805c
Код
Авторство
О чём код?
<?php namespace App\Entity; use App\Repository\UserRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\UserInterface; #[ORM\Entity(repositoryClass: UserRepository::class)] #[ORM\Table(name: '`user`')] #[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: false)] class User implements UserInterface, PasswordAuthenticatedUserInterface { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private $id; #[ORM\Column(type: 'string', length: 255)] private $FIO; #[ORM\Column(type: 'string', length: 255)] private $email; #[ORM\Column(type: 'string', length: 255)] private $password; #[ORM\OneToMany(mappedBy: 'specialist', targetEntity: Card::class)] private Collection $cards; #[ORM\Column(type: "json")] private $roles = []; #[ORM\OneToMany(mappedBy: 'worker', targetEntity: UserService::class)] private Collection $userServices; #[ORM\OneToMany(mappedBy: 'worker', targetEntity: Schedule::class, orphanRemoval: true)] private Collection $schedules; #[ORM\OneToMany(mappedBy: 'worker', targetEntity: Holiday::class, orphanRemoval: true)] private Collection $holidays; #[ORM\Column(name: 'deleted_at', type: Types::DATETIME_MUTABLE, nullable: true)] private $deletedAt; public function __construct() { $this->cards = new ArrayCollection(); $this->userServices = new ArrayCollection(); $this->schedules = new ArrayCollection(); $this->holidays = new ArrayCollection(); } public function getId() : ?int { return $this->id; } public function getFIO() : ?string { return $this->FIO; } public function setFIO(string $FIO) : self { $this->FIO = $FIO; return $this; } public function getEmail() : ?string { return $this->email; } public function setEmail(string $email) : self { $this->email = $email; return $this; } /** * @see PasswordAuthenticatedUserInterface */ public function getPassword() : ?string { return $this->password; } public function setPassword(string $password) : self { $this->password = $password; return $this; } /** * @return Collection<int, Card> */ public function getCards() : Collection { return $this->cards; } public function addCard(Card $card) : self { if (! $this->cards->contains($card)) { $this->cards[] = $card; $card->setSpecialist($this); } return $this; } public function removeCard(Card $card) : self { if ($this->cards->removeElement($card)) { // set the owning side to null (unless already changed) if ($card->getSpecialist() === $this) { $card->setSpecialist(null); } } return $this; } /** * @return array */ public function getRoles() : array { $roles = $this->roles; // guarantee every user at least has ROLE_USER $roles[] = 'ROLE_USER'; return array_unique($roles); } /** * @param array $roles */ public function setRoles(array $roles) : self { $this->roles = $roles; return $this; } public function eraseCredentials() { // TODO: Implement eraseCredentials() method. } public function getUserIdentifier() : string { return (string) $this->email; } public function __toString() : string { return $this->getFIO(); } /** * @return Collection<int, UserService> */ public function getUserServices() : Collection { return $this->userServices; } public function addUserService(UserService $userService) : self { if (! $this->userServices->contains($userService)) { $this->userServices->add($userService); $userService->setWorker($this); } return $this; } public function removeUserService(UserService $userService) : self { if ($this->userServices->removeElement($userService)) { // set the owning side to null (unless already changed) if ($userService->getWorker() === $this) { $userService->setWorker(null); } } return $this; } /** * @return Collection<int, Schedule> */ public function getSchedules() : Collection { return $this->schedules; } public function addSchedule(Schedule $schedule) : self { if (! $this->schedules->contains($schedule)) { $this->schedules->add($schedule); $schedule->setWorker($this); } return $this; } public function removeSchedule(Schedule $schedule) : self { if ($this->schedules->removeElement($schedule)) { // set the owning side to null (unless already changed) if ($schedule->getWorker() === $this) { $schedule->setWorker(null); } } return $this; } /** * @return Collection<int, Holiday> */ public function getHolidays() : Collection { return $this->holidays; } public function addHoliday(Holiday $holiday) : self { if (! $this->holidays->contains($holiday)) { $this->holidays->add($holiday); $holiday->setWorker($this); } return $this; } public function removeHoliday(Holiday $holiday) : self { if ($this->holidays->removeElement($holiday)) { // set the owning side to null (unless already changed) if ($holiday->getWorker() === $this) { $holiday->setWorker(null); } } return $this; } public function getF_I_O() : string { return str_replace(" ", "_", $this->getFIO()); } public function getDeletedAt() : ?\DateTime { return $this->deletedAt; } public function setDeletedAt(?\DateTime $deletedAt) : void { $this->deletedAt = $deletedAt; } }