<?php
# src/Entity/User.php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
#[ORM\Entity]
#[ORM\Table(name: 'users')]
#[ORM\HasLifecycleCallbacks]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $lastname = null;
#[ORM\Column(type: 'string', length: 255, unique: true)]
private ?string $email = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $password = null;
#[ORM\Column(type: 'string', length: 255)]
private string $roles = 'ROLE_USER';
#[ORM\Column(type: 'string', length: 2, nullable: true)]
private ?string $language = 'de';
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $street = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $city = null;
#[ORM\Column(type: 'string', length: 20, nullable: true)]
private ?string $postal_code = null;
#[ORM\Column(type: 'string', length: 100, nullable: true)]
private ?string $country = null;
#[ORM\Column(type: 'string', length: 20, nullable: true)]
private ?string $payment_method = null;
#[ORM\Column(type: 'binary', nullable: true)]
private $credit_card_number = null;
#[ORM\Column(type: 'date', nullable: true)]
private ?\DateTimeInterface $credit_card_expiry = null;
#[ORM\Column(type: 'binary', nullable: true)]
private $credit_card_cvc = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $paypal_token = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $google_token = null;
#[ORM\Column(type: 'datetime')]
private ?\DateTimeInterface $created_at = null;
#[ORM\Column(type: 'datetime')]
private ?\DateTimeInterface $updated_at = null;
#[ORM\Column(type: 'boolean')]
private bool $is_active = true; // Hinzugefügtes Feld für Aktivstatus
#[ORM\OneToMany(targetEntity: Ticket::class, mappedBy: 'user', cascade: ['persist', 'remove'])]
private Collection $tickets;
private ?string $plainPassword = null;
// Füge einen Konstruktor hinzu, um die Tickets-Collection zu initialisieren
public function __construct()
{
$this->tickets = new ArrayCollection();
}
public function getPlainPassword(): ?string
{
return $this->plainPassword;
}
public function setPlainPassword(?string $plainPassword): self
{
$this->plainPassword = $plainPassword;
return $this;
}
// Getters and Setters for all fields
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getRoles(): array
{
return [$this->roles];
}
public function setRoles(array $roles): self
{
$this->roles = $roles[0] ?? 'ROLE_USER';
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(?string $password): self
{
$this->password = $password;
return $this;
}
public function getLanguage(): ?string
{
return $this->language;
}
public function setLanguage(string $language): self
{
$this->language = $language;
return $this;
}
public function getStreet(): ?string
{
return $this->street;
}
public function setStreet(?string $street): self
{
$this->street = $street;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getPostalCode(): ?string
{
return $this->postal_code;
}
public function setPostalCode(?string $postal_code): self
{
$this->postal_code = $postal_code;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
public function getPaymentMethod(): ?string
{
return $this->payment_method;
}
public function setPaymentMethod(string $payment_method): self
{
$this->payment_method = $payment_method;
return $this;
}
public function getCreditCardNumber()
{
return $this->credit_card_number;
}
public function setCreditCardNumber($credit_card_number): self
{
$this->credit_card_number = $credit_card_number;
return $this;
}
public function getCreditCardExpiry(): ?\DateTimeInterface
{
return $this->credit_card_expiry;
}
public function setCreditCardExpiry(?\DateTimeInterface $credit_card_expiry): self
{
$this->credit_card_expiry = $credit_card_expiry;
return $this;
}
public function getCreditCardCvc()
{
return $this->credit_card_cvc;
}
public function setCreditCardCvc($credit_card_cvc): self
{
$this->credit_card_cvc = $credit_card_cvc;
return $this;
}
public function getPaypalToken(): ?string
{
return $this->paypal_token;
}
public function setPaypalToken(?string $paypal_token): self
{
$this->paypal_token = $paypal_token;
return $this;
}
public function getGoogleToken(): ?string
{
return $this->google_token;
}
public function setGoogleToken(?string $google_token): self
{
$this->google_token = $google_token;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->created_at = $createdAt;
return $this;
}
#[ORM\PrePersist]
public function setCreatedAtValue(): void
{
$this->created_at = new \DateTime();
$this->updated_at = new \DateTime();
}
#[ORM\PreUpdate]
public function setUpdatedAtValue(): void
{
$this->updated_at = new \DateTime();
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updated_at = $updatedAt;
return $this;
}
public function getIsActive(): bool
{
return $this->is_active;
}
public function setIsActive(bool $isActive): self
{
$this->is_active = $isActive;
return $this;
}
public function getUserIdentifier(): string
{
return $this->email;
}
public function eraseCredentials(): void
{
// Sensible Daten löschen, falls vorhanden.
}
public function getSalt(): ?string
{
return null;
}
/**
* @return Collection<int, Ticket>
*/
public function getTickets(): Collection
{
return $this->tickets;
}
public function addTicket(Ticket $ticket): self
{
if (!$this->tickets->contains($ticket)) {
$this->tickets[] = $ticket;
$ticket->setUser($this);
}
return $this;
}
public function removeTicket(Ticket $ticket): self
{
if ($this->tickets->removeElement($ticket)) {
// Set the owning side to null (unless already changed)
if ($ticket->getUser() === $this) {
$ticket->setUser(null);
}
}
return $this;
}
}