src/Entity/Stock.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\StockRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=StockRepository::class)
  9.  */
  10. class Stock
  11. {
  12.     public const EXPORT_FIELDS = [
  13.         'reference' => 'Produit',
  14.         'code' => 'Code',
  15.         'price' => 'Prix',
  16.         'stock' => 'Stock'
  17.     ];
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=Produit::class, inversedBy="stocks")
  26.      */
  27.     private $produit;
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity=Siege::class, inversedBy="stocks")
  30.      */
  31.     private $siege;
  32.     /**
  33.      * @ORM\Column(type="integer")
  34.      */
  35.     private $stock;
  36.     /**
  37.      * @ORM\OneToMany(targetEntity=StockUser::class, mappedBy="stock")
  38.      */
  39.     private $stockUsers;
  40.     /**
  41.      * @ORM\Column(type="integer", options={"default": 0})
  42.      */
  43.     private $stockInitial;
  44.     public function __construct()
  45.     {
  46.         $this->stockUsers = new ArrayCollection();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getProduit(): ?Produit
  53.     {
  54.         return $this->produit;
  55.     }
  56.     public function setProduit(?Produit $produit): self
  57.     {
  58.         $this->produit $produit;
  59.         return $this;
  60.     }
  61.     public function getSiege(): ?Siege
  62.     {
  63.         return $this->siege;
  64.     }
  65.     public function setSiege(?Siege $siege): self
  66.     {
  67.         $this->siege $siege;
  68.         return $this;
  69.     }
  70.     public function getStock(): ?int
  71.     {
  72.         return $this->stock;
  73.     }
  74.     public function setStock(int $stock): self
  75.     {
  76.         $this->stock $stock;
  77.         return $this;
  78.     }
  79.     /**
  80.      * @return Collection<int, StockUser>
  81.      */
  82.     public function getStockUsers(): Collection
  83.     {
  84.         return $this->stockUsers;
  85.     }
  86.     public function addStockUser(StockUser $stockUser): self
  87.     {
  88.         if (!$this->stockUsers->contains($stockUser)) {
  89.             $this->stockUsers[] = $stockUser;
  90.             $stockUser->setStock($this);
  91.         }
  92.         return $this;
  93.     }
  94.     public function removeStockUser(StockUser $stockUser): self
  95.     {
  96.         if ($this->stockUsers->removeElement($stockUser)) {
  97.             // set the owning side to null (unless already changed)
  98.             if ($stockUser->getStock() === $this) {
  99.                 $stockUser->setStock(null);
  100.             }
  101.         }
  102.         return $this;
  103.     }
  104.     public function getStockInitial(): ?int
  105.     {
  106.         return $this->stockInitial;
  107.     }
  108.     public function setStockInitial(int $stockInitial): self
  109.     {
  110.         $this->stockInitial $stockInitial;
  111.         return $this;
  112.     }
  113. }