Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: Maciek
- * Date: 29.12.2016
- * Time: 18:16
- */
- namespace AppBundle\Entity;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- use Symfony\Component\Security\Core\User\UserInterface;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * @ORM\Entity
- * @ORM\Table(name="user")
- * @UniqueEntity(fields={"email"}, message="Podany email jest już w zajety")
- */
- class User implements UserInterface
- {
- public function __construct()
- {
- $this->restaurants = new ArrayCollection();
- }
- /**
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- * @ORM\Column(type="integer")
- */
- private $id;
- /**
- * @Assert\NotBlank()
- * @Assert\Email()
- * @ORM\Column(type="string", unique=true)
- */
- private $email;
- /**
- * @Assert\NotBlank(groups={"Registration"})
- * @ORM\Column(type="string")
- */
- private $name;
- /**
- * @Assert\NotBlank(groups={"Registration"})
- * @ORM\Column(type="string")
- */
- private $surname;
- /**
- * @ORM\Column(type="string")
- */
- private $password;
- /**
- * @Assert\NotBlank(message="Podaj hasło", groups={"Registration"})
- */
- private $plainPassword;
- /**
- * @ORM\Column(type="json_array")
- */
- private $roles = [];
- /**
- * @ORM\Column(type="string", nullable=true)
- * @Assert\Image(
- * minWidth="128",
- * minHeight="128",
- * mimeTypes={"image/jpeg", "image/gif", "image/png", "image/jpg"}
- * )
- */
- private $avatar;
- /**
- * @ORM\OneToMany(targetEntity="AppBundle\Entity\Restaurant", mappedBy="owner")
- */
- private $restaurants;
- public function getUsername()
- {
- return $this->email;
- }
- public function getRoles()
- {
- $roles = $this->roles;
- if (!in_array('ROLE_USER', $roles)){
- $roles[] = 'ROLE_USER';
- }
- return $roles;
- }
- /**
- * @param mixed $roles
- */
- public function setRoles(array $roles)
- {
- $this->roles = $roles;
- }
- public function getPassword()
- {
- return $this->password;
- }
- public function getSalt()
- {
- }
- public function eraseCredentials()
- {
- $this->plainPassword = null;
- }
- public function setEmail($email)
- {
- $this->email = $email;
- }
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * @param mixed $password
- */
- public function setPassword($password)
- {
- $this->password = $password;
- }
- /**
- * @return mixed
- */
- public function getPlainPassword()
- {
- return $this->plainPassword;
- }
- /**
- * @param mixed $plainPassword
- */
- public function setPlainPassword($plainPassword)
- {
- $this->plainPassword = $plainPassword;
- $this->password = null;
- }
- /**
- * @return mixed
- */
- public function getName()
- {
- return $this->name;
- }/**
- * @param mixed $name
- */
- public function setName($name)
- {
- $this->name = $name;
- }/**
- * @return mixed
- */
- public function getSurname()
- {
- return $this->surname;
- }/**
- * @param mixed $surname
- */
- public function setSurname($surname)
- {
- $this->surname = $surname;
- }
- /**
- * @return mixed
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @return ArrayCollection|User
- */
- public function getRestaurants()
- {
- return $this->restaurants;
- }
- /**
- * @return mixed
- */
- public function getAvatar()
- {
- return $this->avatar;
- }
- /**
- * @param mixed $avatar
- */
- public function setAvatar($avatar)
- {
- $this->avatar = $avatar;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement