src/Entity/OrderAssignment.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\OrderAssignmentRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Timestampable\Traits\TimestampableEntity;
  6. #[ORM\Entity(repositoryClassOrderAssignmentRepository::class)]
  7. #[ORM\Index(columns: ['order_item_id''user_id'], name'order_user_idx')]
  8. class OrderAssignment
  9. {
  10.     use TimestampableEntity;
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\ManyToOne(inversedBy'orderAssignments'cascade: ['persist'])]
  16.     private ?Order $orderItem null;
  17.     #[ORM\ManyToOne(inversedBy'orderAssignments'fetch'EAGER')]
  18.     private ?User $user null;
  19.     #[ORM\Column]
  20.     private ?int $splitPercent 100;
  21.     public function getId(): ?int
  22.     {
  23.         return $this->id;
  24.     }
  25.     public function getOrderItem(): ?Order
  26.     {
  27.         return $this->orderItem;
  28.     }
  29.     public function setOrderItem(?Order $orderItem): static
  30.     {
  31.         $this->orderItem $orderItem;
  32.         return $this;
  33.     }
  34.     public function getUser(): ?User
  35.     {
  36.         return $this->user;
  37.     }
  38.     public function setUser(?User $user): static
  39.     {
  40.         $this->user $user;
  41.         return $this;
  42.     }
  43.     public function getSplitPercent(): ?int
  44.     {
  45.         return $this->splitPercent;
  46.     }
  47.     public function setSplitPercent(int $splitPercent): static
  48.     {
  49.         $this->splitPercent $splitPercent;
  50.         return $this;
  51.     }
  52.     // add to string the id of the order
  53.     public function __toString()
  54.     {
  55.         return sprintf('%s - %s'$this->getUser(), $this->getSplitPercent());
  56.     }
  57. }