src/Entity/CreditCost.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Enum\CreditCostStateEnum;
  4. use App\Repository\CreditCostRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass=CreditCostRepository::class)
  8.  * @ORM\EntityListeners({"App\Listener\CreditCostListener"})
  9.  */
  10. class CreditCost
  11. {
  12.     /**
  13.      * Nb of credit to "buy" a prospect.
  14.      */
  15.     const NB_CREDIT_ONE_PROSPECT 1;
  16.     /**
  17.      * @ORM\Id()
  18.      * @ORM\GeneratedValue()
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private int $id;
  22.     /**
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private int $nbCredit;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=Freelancer::class, inversedBy="creditCosts")
  28.      */
  29.     private ?Freelancer  $administrator;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=CentralPurchasing::class, inversedBy="creditCosts")
  32.      */
  33.     private ?CentralPurchasing $centralPurchasing;
  34.     /**
  35.      * State: manage the state of the credit cost if it was created in a "pay as you go" mode.
  36.      * @ORM\Column(type="string", length=5, nullable=true)
  37.      */
  38.     private ?string $state=null;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity=Order::class, inversedBy="creditCosts")
  41.      */
  42.     private ?Order $order;
  43.     /**
  44.      * @ORM\OneToOne(targetEntity=ProspectOnStore::class, mappedBy="cost")
  45.      */
  46.     private $prospectOnStore;
  47.     /**
  48.      * CreditCost constructor.
  49.      * - A prospect is cost 1 crédit by default
  50.      */
  51.     public function __construct()
  52.     {
  53.         $this->setNbCredit(self::NB_CREDIT_ONE_PROSPECT);
  54.     }
  55.     public function getId(): ?int
  56.     {
  57.         return $this->id;
  58.     }
  59.     public function getNbCredit(): ?int
  60.     {
  61.         return $this->nbCredit;
  62.     }
  63.     public function setNbCredit(int $nbCredit): self
  64.     {
  65.         $this->nbCredit $nbCredit;
  66.         return $this;
  67.     }
  68.     public function getAdministrator(): ?Administrator
  69.     {
  70.         return $this->administrator;
  71.     }
  72.     public function getFreelancer(): ?Freelancer
  73.     {
  74.         return $this->administrator;
  75.     }
  76.     public function setAdministrator(?Administrator $administrator): self
  77.     {
  78.         $this->administrator $administrator;
  79.         return $this;
  80.     }
  81.     public function getCentralPurchasing(): ?CentralPurchasing
  82.     {
  83.         return $this->centralPurchasing;
  84.     }
  85.     public function setCentralPurchasing(?CentralPurchasing $centralPurchasing): self
  86.     {
  87.         $this->centralPurchasing $centralPurchasing;
  88.         return $this;
  89.     }
  90.     public function getState(): ?string
  91.     {
  92.         return $this->state;
  93.     }
  94.     public function getStateLabel(): ?string
  95.     {
  96.         return is_null($this->state)?'':CreditCostStateEnum::getStateName($this->state);
  97.     }
  98.     public function markAsPending(): void
  99.     {
  100.         $this->state CreditCostStateEnum::STATE_PENDING;
  101.     }
  102.     public function isPending(): bool
  103.     {
  104.         return $this->state == CreditCostStateEnum::STATE_PENDING;
  105.     }
  106.     public function markAsBilled(): void
  107.     {
  108.         $this->state CreditCostStateEnum::STATE_BILLED;
  109.     }
  110.     public function getOrder(): ?Order
  111.     {
  112.         return $this->order;
  113.     }
  114.     public function setOrder(?Order $order): void
  115.     {
  116.         $this->order $order;
  117.     }
  118.     /**
  119.      * @return mixed
  120.      */
  121.     public function getProspectOnStore()
  122.     {
  123.         return $this->prospectOnStore;
  124.     }
  125.     /**
  126.      * @param mixed $prospectOnStore
  127.      */
  128.     public function setProspectOnStore($prospectOnStore): void
  129.     {
  130.         $this->prospectOnStore $prospectOnStore;
  131.     }
  132. }