src/Entity/SelectionPart.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SelectionPartRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Serializer\Annotation as Serializer;
  6. use Symfony\Component\Serializer\Annotation\SerializedName;
  7. use App\Annotation\DashboardAnnotation as Dashboard;
  8. /**
  9.  * @ORM\Entity(repositoryClass=SelectionPartRepository::class)
  10.  * @Dashboard(generation=true, name="Данные подбора запчастей")
  11.  */
  12. class SelectionPart
  13. {
  14.      /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      * @Serializer\Groups({"collection"}) 
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\ManyToOne(targetEntity=Modification::class, inversedBy="selectionParts")
  23.      * @Serializer\Groups({"collection"}) 
  24.      */
  25.     private $modification;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=ProductOem::class, inversedBy="selectionParts")
  28.      * @Serializer\Groups({"collection"}) 
  29.      */
  30.     private $productOem;
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getModification(): ?Modification
  36.     {
  37.         return $this->modification;
  38.     }
  39.     public function setModification(?Modification $modification): self
  40.     {
  41.         $this->modification $modification;
  42.         return $this;
  43.     }
  44.     public function getProductOem(): ?ProductOem
  45.     {
  46.         return $this->productOem;
  47.     }
  48.     public function setProductOem(?ProductOem $productOem): self
  49.     {
  50.         $this->productOem $productOem;
  51.         return $this;
  52.     }
  53.     /**
  54.      * @Serializer\Groups({"selection/applicable"}) 
  55.      * @SerializedName("title")
  56.      */
  57.     public function getApplicableTitle(): string
  58.     {
  59.         $title '';
  60.         
  61.         if ($modification $this->getModification()) {
  62.             $title $modification->getModel()->getMark()->getTitle() . ' ' $modification->getModel()->getTitle() . ' [' $modification->getParams() .']';
  63.         }
  64.         return $title;
  65.     }
  66.     /**
  67.      * @Serializer\Groups({"selection/applicable"}) 
  68.      */
  69.     public function getRef(): array
  70.     {
  71.         if ($modification $this->getModification()) {
  72.             return [
  73.                 //'modification' => $modification->getId(),
  74.                 'mark' => $modification->getModel()->getMark()->getId(),
  75.                 'model' => $modification->getModel()->getId(),
  76.                 'body' => $modification->getBody(),
  77.                 'years' => ($modification->getYearFrom() ?? '') . '|' . ($modification->getYearTo() ?? '')
  78.             ];
  79.         }
  80.         return [];
  81.     }
  82. }