<?php
namespace App\Entity;
use App\Entity\User;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Purchase instruction rules.
* Each user can set how many cars he wants to buy during each sale.
*
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
*
* @ORM\Entity(repositoryClass="App\Repository\PurchaseInstructionRuleRepository")
*
* @ORM\Table(name="purchase_instruction_rule")
*/
class PurchaseInstructionRule
{
/**
* @ORM\Id
*
* @ORM\Column(type="bigint")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="purchaseInstructionRules")
*
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Sale", inversedBy="purchaseInstructionRules")
*
* @ORM\JoinColumn(name="sale_id", referencedColumnName="id")
*/
protected $sale;
/**
* @Gedmo\Timestampable(on="create")
*
* @ORM\Column(type="datetime", name="created_at")
*/
protected $createdAt;
/**
* @Gedmo\Timestampable(on="update")
*
* @ORM\Column(type="datetime", name="updated_at")
*/
protected $updatedAt;
public function __construct(User $user, Sale $sale, /**
* @ORM\Column(type="integer")
*
* @Assert\Range(min = 1)
*/
protected $quantity = 1)
{
$this->user = $user;
$this->sale = $sale;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Returns user.
*
* @return App\Entity\User
*/
public function getUser()
{
return $this->user;
}
/**
* Sets user.
*
* @param App\Entity\User $user
*/
public function setUser(?User $user = null): void
{
$this->user = $user;
}
/**
* Returns the sale.
*
* @return App\Entity\Sale
*/
public function getSale()
{
return $this->sale;
}
/**
* Sets the sale.
*/
public function setSale(Sale $sale): void
{
$this->sale = $sale;
}
/**
* Returns the quantity of vehicles.
*
* @return int
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* Sets the quantity of vehicles.
*
* @param int $quantity
*/
public function setQuantity($quantity): void
{
$this->quantity = $quantity;
}
/**
* Returns time of creation.
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Sets time of creation.
*/
public function setCreatedAt(\DateTime $createdAt): void
{
$this->createdAt = $createdAt;
}
/**
* Returns time of update.
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Sets time of update.
*/
public function setUpdatedAt(\DateTime $updatedAt): void
{
$this->updatedAt = $updatedAt;
}
}