You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OrderProduct.php 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Lc\ShopBundle\Context\PriceInterface;
  5. /**
  6. * @ORM\MappedSuperclass()
  7. */
  8. abstract class OrderProduct extends AbstractEntity implements PriceInterface
  9. {
  10. use PriceTrait ;
  11. /**
  12. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="orderProducts", cascade={"persist"})
  13. * @ORM\JoinColumn(nullable=false)
  14. */
  15. protected $orderShop;
  16. /**
  17. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ProductInterface")
  18. */
  19. protected $product;
  20. /**
  21. * @ORM\Column(type="float")
  22. */
  23. protected $quantity;
  24. /**
  25. * @ORM\Column(type="string", length=255)
  26. */
  27. protected $title;
  28. public function __toString()
  29. {
  30. if($this->getTitle()) {
  31. return $this->getTitle();
  32. }else{
  33. return $this->getProduct()->getProductFamily()->getTitle(). ' - '.$this->getProduct()->getTitle();
  34. }
  35. }
  36. public function getOrderShop(): ?OrderShop
  37. {
  38. return $this->orderShop;
  39. }
  40. public function setOrderShop(?OrderShop $orderShop): self
  41. {
  42. $this->orderShop = $orderShop;
  43. return $this;
  44. }
  45. public function getProduct(): ?Product
  46. {
  47. return $this->product;
  48. }
  49. public function setProduct(?Product $product): self
  50. {
  51. $this->product = $product;
  52. return $this;
  53. }
  54. public function getQuantity(): ?float
  55. {
  56. return $this->quantity;
  57. }
  58. public function setQuantity(float $quantity): self
  59. {
  60. $this->quantity = $quantity;
  61. return $this;
  62. }
  63. public function getTitle(): ?string
  64. {
  65. return $this->title;
  66. }
  67. public function setTitle(string $title): self
  68. {
  69. $this->title = $title;
  70. return $this;
  71. }
  72. }