src/Entity/ServiceUser.php line 17

Open in your IDE?
  1. <?php
  2.     namespace App\Entity;
  3.     use App\Repository\ServiceUserRepository;
  4.     use App\Traits\DateTrait;
  5.     use Doctrine\ORM\Mapping as ORM;
  6.     use JMS\Serializer\Annotation as Serializer;
  7.     use JMS\Serializer\Annotation\Expose;
  8.     use JMS\Serializer\Annotation\Groups;
  9.     /**
  10.      * @ORM\Entity(repositoryClass=ServiceUserRepository::class)
  11.      *
  12.      * @Serializer\ExclusionPolicy("ALL")
  13.      */
  14.     class ServiceUser
  15.     {
  16.         const PENDING    0;
  17.         const PROCESSING 1;
  18.         const TERMINATE  2;
  19.         /**
  20.          * @ORM\Id
  21.          * @ORM\GeneratedValue
  22.          * @ORM\Column(type="integer")
  23.          *
  24.          * @Expose
  25.          * @Groups({"service_user"})
  26.          */
  27.         private $id;
  28.         /**
  29.          * @ORM\ManyToOne(targetEntity=User::class, inversedBy="serviceUsers")
  30.          * @ORM\JoinColumn(nullable=false)
  31.          *
  32.          * @Expose
  33.          * @Groups({"service_user"})
  34.          */
  35.         private $user;
  36.         /**
  37.          * @ORM\Column(type="text")
  38.          *
  39.          * @Expose
  40.          * @Groups({"service_user"})
  41.          */
  42.         private $content;
  43.         /**
  44.          * @ORM\Column(type="integer")
  45.          *
  46.          * @Expose
  47.          * @Groups({"service_user"})
  48.          */
  49.         private $quantity;
  50.         /**
  51.          * @ORM\Column(type="integer")
  52.          *
  53.          * @Expose
  54.          * @Groups({"service_user"})
  55.          */
  56.         private $status;
  57.         /**
  58.          * @ORM\Column(type="string", length=255)
  59.          */
  60.         private $image;
  61.         /**
  62.          * @ORM\Column(type="string", length=255)
  63.          */
  64.         private $title;
  65.         /**
  66.          * @ORM\Column(type="text")
  67.          */
  68.         private $description;
  69.         use DateTrait;
  70.         public function __construct()
  71.         {
  72.             $this->status $this::PENDING;
  73.         }
  74.         public function getId(): ?int
  75.         {
  76.             return $this->id;
  77.         }
  78.         public function getUser(): ?User
  79.         {
  80.             return $this->user;
  81.         }
  82.         public function setUser( ?User $user ): self
  83.         {
  84.             $this->user $user;
  85.             return $this;
  86.         }
  87.         public function getContent(): ?string
  88.         {
  89.             return $this->content;
  90.         }
  91.         public function setContentstring $content ): self
  92.         {
  93.             $this->content $content;
  94.             return $this;
  95.         }
  96.         public function getQuantity(): ?int
  97.         {
  98.             return $this->quantity;
  99.         }
  100.         public function setQuantityint $quantity ): self
  101.         {
  102.             $this->quantity $quantity;
  103.             return $this;
  104.         }
  105.         public function getStatus(): ?int
  106.         {
  107.             return $this->status;
  108.         }
  109.         public function setStatusint $status ): self
  110.         {
  111.             $this->status $status;
  112.             return $this;
  113.         }
  114.         public function getHumanizedStatus(): string
  115.         {
  116.             $labels = [
  117.                 'en attente de traitement',
  118.                 'en cours de traitement',
  119.                 'traité'
  120.             ];
  121.             return $labels[$this->status];
  122.         }
  123.         public function getImage(): ?string
  124.         {
  125.             return $this->image;
  126.         }
  127.         public function setImage(string $image): self
  128.         {
  129.             $this->image $image;
  130.             return $this;
  131.         }
  132.         public function getTitle(): ?string
  133.         {
  134.             return $this->title;
  135.         }
  136.         public function setTitle(string $title): self
  137.         {
  138.             $this->title $title;
  139.             return $this;
  140.         }
  141.         public function getDescription(): ?string
  142.         {
  143.             return $this->description;
  144.         }
  145.         public function setDescription(string $description): self
  146.         {
  147.             $this->description $description;
  148.             return $this;
  149.         }
  150.     }