Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ukol 3 - Tomáš Linhart #31

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/AppBundle/Entity/Adress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* @author Tomáš Linhart <[email protected]>
*
* @ORM\Entity(repositoryClass="AppBundle\Repository\AddressRepository")
*/
class Address
{

/**
* @var int
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;

/**
* @var string
* @ORM\Column(type="string")
*/
private $name;

/**
* @var string
* @ORM\Column(type="string")
*/
private $city;

/**
* @var string
* @ORM\Column(type="string")
*/
private $street;

/**
* @var int
* @ORM\Column(type="integer")
*/
private $zip;

}
98 changes: 89 additions & 9 deletions src/AppBundle/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author Vašek Boch <[email protected]>
* @author Jan Klat <[email protected]>
* @ORM\Entity
* @UniqueEntity(fields="username", message="Tento e-mail je již registrován")
* @UniqueEntity(fields="username", message="Toto uživatelské jméno je již registrováno")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zajímavé řešení. :) Neznal jsem :)

*/
class User implements UserInterface
{
Expand All @@ -24,23 +24,47 @@ class User implements UserInterface
private $id;

/**
* @ORM\Column(type="string", length=255, unique=true, name="email")
* @var string
* @ORM\Column(type="string", length=255, unique=true, name="username")
* @Assert\NotBlank()
* @Assert\Email()
* @Assert\Blank(groups={"passwordReset"})
*/
private $username;

/**
* @var string
* @ORM\Column(type="string", length=64)
* @Assert\NotBlank(groups={"profileSetup"})
*/
private $password;

/**
* @var string
* @Assert\NotBlank()
* @Assert\Length(max=4096)
*/
private $plainPassword;

/**
* @var string
* @ORM\Column(type="string", length=255, name="name", nullable=true)
*/
private $name;

/**
* @var string
* @ORM\Column(type="string", length=255, unique=true, name="email", nullable=true)
* @Assert\Email()
*/
private $email;

/**
* @var string
* @ORM\Column(type="string", length=255, unique=true, name="phone", nullable=true)
* @Assert\Email()
*/
private $phone;

/**
* @return int
*/
Expand All @@ -60,15 +84,15 @@ public function setId($id)
}

/**
* @return mixed
* @return string
*/
public function getUsername()
{
return $this->username;
}

/**
* @param mixed $username
* @param string $username
* @return self
*/
public function setUsername($username)
Expand All @@ -78,15 +102,15 @@ public function setUsername($username)
}

/**
* @return mixed
* @return string
*/
public function getPassword()
{
return $this->password;
}

/**
* @param mixed $password
* @param string $password
* @return self
*/
public function setPassword($password)
Expand All @@ -96,15 +120,15 @@ public function setPassword($password)
}

/**
* @return mixed
* @return string
*/
public function getPlainPassword()
{
return $this->plainPassword;
}

/**
* @param mixed $plainPassword
* @param string $plainPassword
* @return self
*/
public function setPlainPassword($plainPassword)
Expand All @@ -129,4 +153,60 @@ public function eraseCredentials()
return;
}

// profile specification

/**
* @return string
*/
public function getName()
{
return $this->name;
}

/**
* @param string $name
* @return self
*/
public function setName($name)
{
$this->name = $name;
return $this;
}

/**
* @return string
*/
public function getEmail()
{
return $this->email;
}

/**
* @param string $email
* @return self
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}

/**
* @return string
*/
public function getPhone()
{
return $this->phone;
}

/**
* @param string $phone
* @return self
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}

}
77 changes: 77 additions & 0 deletions src/AppBundle/Entity/UserAddress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* @author Tomáš Linhart <[email protected]>
*
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserAddressRepository")
* @ORM\Table(name="user_address")
*/
class UserAddress
{

/**
* @var int
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;

/**
* @var User
* @ORM\ManyToOne(targetEntity="User")
*/
private $user;

/**
* @var Address
* @ORM\ManyToOne(targetEntity="Address")
*/
private $address;

/**
* @return int
*/
public function getId() {
return $this->id;
}

/**
* @return User
*/
public function getUser() {
return $this->user;
}

/**
* @param User $user
* @return self
*/
public function setUser(User $user) {
$this->user = $user;
return $this;
}

/**
* @return Address
*/
public function getAddress()
{
return $this->address;
}

/**
* @param Address $address
* @return self
*/
public function setAddress(Address $address)
{
$this->address = $address;
return $this;
}

}
9 changes: 9 additions & 0 deletions src/AppBundle/Repository/AddressRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace AppBundle\Repository;

use Doctrine\ORM\EntityRepository;

class AddressRepository extends EntityRepository
{
}
9 changes: 9 additions & 0 deletions src/AppBundle/Repository/UserAddressRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace AppBundle\Repository;

use Doctrine\ORM\EntityRepository;

class UserAddressRepository extends EntityRepository
{
}