src/Entity/OrderStatus.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\OrderStatusRepository;
  4. use Doctrine\Bundle\DoctrineBundle\Attribute\AsEntityListener;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Events;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Blameable\Traits\BlameableEntity;
  10. use Gedmo\Timestampable\Traits\TimestampableEntity;
  11. #[ORM\Entity(repositoryClassOrderStatusRepository::class)]
  12. class OrderStatus extends BaseKeyValue
  13. {
  14.     use BlameableEntity//Hook blameable behaviour. Updates createdBy, updatedBy fields
  15.     use TimestampableEntity//Hook timestampable behaviour. Updates createdAt, updatedAt fields 
  16.     
  17.     const PENDING_PAYMENT 'PENDING_PAYMENT';  // User hasn't pre-authorized the purchase of the order
  18.     const MONEY_WITHHELD 'MONEY_WITHHELD';    // User has pre-authorized the purchase of the order
  19.     const NOT_SOLD 'NOT_SOLD';                // Incomplete order because we haven't reach the minimum qty in the ProductPriceScale. We cancelled the pre-authorization
  20.     const PAID 'PAID';                        // User has paid the order
  21.     const SENT 'SENT';                        // Product has been sent
  22.     const RECEIVED 'RECEIVED';                // Product has been received
  23.     const CANCELED 'CANCELED';                // Product has been cancelled by User
  24.     const BANK_TRANSFER 'BANK_TRANSFER';
  25.     const PENDING_TRANSFER 'PENDING_TRANSFER';
  26.     const CONFIRMED_TRANSFER 'CONFIRMED_TRANSFER';
  27.     
  28.     #[ORM\Id]
  29.     #[ORM\GeneratedValue(strategy"IDENTITY")]
  30.     #[ORM\Column]
  31.     private ?int $id null;
  32.     #[ORM\OneToMany(mappedBy'status'targetEntityOrder::class)]
  33.     private Collection $orders;
  34.     public function __construct()
  35.     {
  36.         $this->orders = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     /**
  43.      * @return Collection<int, Order>
  44.      */
  45.     public function getOrders(): Collection
  46.     {
  47.         return $this->orders;
  48.     }
  49.     public function addOrder(Order $order): self
  50.     {
  51.         if (!$this->orders->contains($order)) {
  52.             $this->orders->add($order);
  53.             $order->setStatus($this);
  54.         }
  55.         return $this;
  56.     }
  57.     public function removeOrder(Order $order): self
  58.     {
  59.         if ($this->orders->removeElement($order)) {
  60.             // set the owning side to null (unless already changed)
  61.             if ($order->getStatus() === $this) {
  62.                 $order->setStatus(null);
  63.             }
  64.         }
  65.         return $this;
  66.     }
  67. }