sf-api-example/src/AppBundle/Entity/Author.php
2016-11-23 16:10:52 +01:00

145 lines
2.4 KiB
PHP

<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Author
*
* @ORM\Table(name="author")
* @ORM\Entity(repositoryClass="AppBundle\Repository\AuthorRepository")
*/
class Author
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="firstname", type="string", length=255)
*/
private $firstname;
/**
* @var string
*
* @ORM\Column(name="lastname", type="string", length=255)
*/
private $lastname;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\OneToMany(targetEntity="Book", mappedBy="author", cascade={"persist"})
*/
private $books;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set firstname
*
* @param string $firstname
*
* @return Author
*/
public function setFirstname($firstname)
{
$this->firstname = $firstname;
return $this;
}
/**
* Get firstname
*
* @return string
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* Set lastname
*
* @param string $lastname
*
* @return Author
*/
public function setLastname($lastname)
{
$this->lastname = $lastname;
return $this;
}
/**
* Get lastname
*
* @return string
*/
public function getLastname()
{
return $this->lastname;
}
/**
* Constructor
*/
public function __construct()
{
$this->books = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add book
*
* @param \AppBundle\Entity\Book $book
*
* @return Author
*/
public function addBook(\AppBundle\Entity\Book $book)
{
$this->books[] = $book;
return $this;
}
/**
* Remove book
*
* @param \AppBundle\Entity\Book $book
*/
public function removeBook(\AppBundle\Entity\Book $book)
{
$this->books->removeElement($book);
}
/**
* Get books
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getBooks()
{
return $this->books;
}
}