166 lines
2.9 KiB
PHP
166 lines
2.9 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace KekRozsak\FrontBundle\Entity;
|
||
|
|
||
|
use Doctrine\ORM\Mapping as ORM;
|
||
|
use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
|
||
|
|
||
|
use KekRozsak\FrontBundle\Entity\Book;
|
||
|
use KekRozsak\SecurityBundle\Entity\User;
|
||
|
|
||
|
/**
|
||
|
* KekRozsak\FrontBundle\Entity\BookCopy
|
||
|
* @ORM\Entity
|
||
|
* @ORM\Table(name="book_copies", uniqueConstraints={
|
||
|
* @ORM\UniqueConstraint(columns={"owner_id", "book_id"})
|
||
|
* })
|
||
|
*
|
||
|
* @DoctrineAssert\UniqueEntity(fields={"owner_id", "book_id"})
|
||
|
*/
|
||
|
class BookCopy
|
||
|
{
|
||
|
public function __construct(Book $book, User $owner)
|
||
|
{
|
||
|
$this->book = $book;
|
||
|
$this->owner = $owner;
|
||
|
$this->borrowable = false;
|
||
|
$this->buyable = false;
|
||
|
$this->borrower = null;
|
||
|
$this->borrowerReturned = true;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @var integer $id
|
||
|
*
|
||
|
* @ORM\Id
|
||
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||
|
* @ORM\Column(type="integer")
|
||
|
*/
|
||
|
protected $id;
|
||
|
|
||
|
/**
|
||
|
* @var KekRozsak\FrontBundle\Entity\Book $book
|
||
|
*
|
||
|
* @ORM\ManyToOne(targetEntity="Book", inversedBy="copies")
|
||
|
* @ORM\JoinColumn(nullable=false)
|
||
|
*/
|
||
|
protected $book;
|
||
|
|
||
|
/**
|
||
|
* @var KekRozsak\SecurityBundle\Entity\User $owner
|
||
|
*
|
||
|
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||
|
* @ORM\JoinColumn(nullable=false)
|
||
|
*/
|
||
|
protected $owner;
|
||
|
|
||
|
/**
|
||
|
* Get owner
|
||
|
*
|
||
|
* @return KekRozsak\SecurityBundle\Entity\User
|
||
|
*/
|
||
|
public function getOwner()
|
||
|
{
|
||
|
return $this->owner;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @var string $ownerComment
|
||
|
*
|
||
|
* @ORM\Column(type="text", name="owner_comment", nullable=true)
|
||
|
*/
|
||
|
protected $ownerComment;
|
||
|
|
||
|
/**
|
||
|
* @var boolean $borrowable
|
||
|
*
|
||
|
* @ORM\Column(type="boolean", nullable=false)
|
||
|
*/
|
||
|
protected $borrowable;
|
||
|
|
||
|
/**
|
||
|
* Set borrowable
|
||
|
*
|
||
|
* @param boolean $borrowable
|
||
|
* @return BookCopy
|
||
|
*/
|
||
|
public function setBorrowable($borrowable)
|
||
|
{
|
||
|
$this->borrowable = $borrowable;
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get borrowable
|
||
|
*
|
||
|
* @return boolean
|
||
|
*/
|
||
|
public function isBorrowable()
|
||
|
{
|
||
|
return $this->borrowable;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @var boolean $buyable
|
||
|
*
|
||
|
* @ORM\Column(type="boolean", nullable=false)
|
||
|
*/
|
||
|
protected $buyable;
|
||
|
|
||
|
/**
|
||
|
* Set buyable
|
||
|
*
|
||
|
* @param boolean $buyable
|
||
|
* @return BookCopy
|
||
|
*/
|
||
|
public function setBuyable($buyable)
|
||
|
{
|
||
|
$this->buyable = $buyable;
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get borrowable
|
||
|
*
|
||
|
* @return boolean
|
||
|
*/
|
||
|
public function isBuyable()
|
||
|
{
|
||
|
return $this->buyable;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @var KekRozsak\SecurityBundle\Entity\User $borrower
|
||
|
*
|
||
|
* @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||
|
*/
|
||
|
protected $borrower;
|
||
|
|
||
|
/**
|
||
|
* Get borrower
|
||
|
*
|
||
|
* @return KekRozsak\SecurityBundle\Entity\User
|
||
|
*/
|
||
|
public function getBorrower()
|
||
|
{
|
||
|
return $this->borrower;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @var boolean $borrowerReturned
|
||
|
*
|
||
|
* @ORM\Column(type="boolean", nullable=false, name="borrower_returned")
|
||
|
*/
|
||
|
protected $borrowerReturned;
|
||
|
|
||
|
/**
|
||
|
* Get borrowerReturned
|
||
|
*
|
||
|
* @return boolean
|
||
|
*/
|
||
|
public function isBorrowerReturned()
|
||
|
{
|
||
|
return $this->borrowerReturned();
|
||
|
}
|
||
|
}
|