apps/backend/src/Entity/Vehicle.php line 21

  1. <?php
  2. namespace Backend\Entity;
  3. use Backend\Repository\VehicleRepository;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * Vehicle
  8.  *
  9.  */
  10. #[ORM\Table(name'vehicle')]
  11. #[ORM\Index(columns: ['fuel_type_id'], name'fk_vehicle_fuel_type1_idx')]
  12. #[ORM\Index(columns: ['traction_type_id'], name'fk_vehicle_traction_type_idx')]
  13. #[ORM\Index(columns: ['transmission_type_id'], name'fk_vehicle_transmission_type_idx')]
  14. #[ORM\Index(columns: ['model_vehicle_id'], name'fk_vehicle_model_vehicle1_idx')]
  15. #[ORM\Index(columns: ['vehicle_direction_id'], name'fk_vehicle_direction_idx')]
  16. #[ORM\Entity(repositoryClassVehicleRepository::class)]
  17. #[ORM\HasLifecycleCallbacks]
  18. class Vehicle
  19. {
  20.     /**
  21.      * @var int
  22.      *
  23.      */
  24.     #[ORM\Column(name'id'type'integer'nullablefalse)]
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  27.     private $id;
  28.     #[ORM\Column(name'year_model'type'integer'nullablefalse)]
  29.     private int $yearModel;
  30.     #[ORM\Column(name'image_thumbnail'type'string'length150nullablefalse)]
  31.     private string $imageThumbnail;
  32.     #[ORM\Column(name'number_cylinder'type'boolean'nullablefalse)]
  33.     private bool $numberCylinder;
  34.     #[ORM\Column(name'status'type'boolean'nullablefalse)]
  35.     private bool $status;
  36.     #[ORM\Column(name'create_date'type'datetime'nullablefalse)]
  37.     private $createDate;
  38.     #[ORM\Column(name'update_date'type'datetime'nullabletrueoptions: ['default' => null])]
  39.     private \DateTimeInterface $updateDate;
  40.     #[ORM\JoinColumn(name'model_vehicle_id'referencedColumnName'id')]
  41.     #[ORM\ManyToOne(targetEntity'Model')]
  42.     private Model $model;
  43.     #[ORM\JoinColumn(name'transmission_type_id'referencedColumnName'id')]
  44.     #[ORM\ManyToOne(targetEntity'TransmissionType')]
  45.     private TransmissionType $transmissionType;
  46.     #[ORM\Column(name'number_door'type'integer'nullablefalse)]
  47.     private int $numberDoor;
  48.     #[ORM\Column(name'number_passenger'type'integer'nullablefalse)]
  49.     private int $numberPassenger;
  50.     #[ORM\JoinColumn(name'fuel_type_id'referencedColumnName'id')]
  51.     #[ORM\ManyToOne(targetEntity'FuelType')]
  52.     private FuelType $fuelType;
  53.     #[ORM\JoinColumn(name'traction_type_id'referencedColumnName'id')]
  54.     #[ORM\ManyToOne(targetEntity'TractionType')]
  55.     private TractionType $tractionType;
  56.     #[ORM\JoinColumn(name'vehicle_direction_id'referencedColumnName'id')]
  57.     #[ORM\ManyToOne(targetEntity'VehicleDirection')]
  58.     private VehicleDirection $vehicleDirection;
  59.     
  60.     #[ORM\OneToMany(mappedBy'vehicle'targetEntity'VehicleCategoryBlock')]
  61.     private $categoriesBlock;
  62.     #[ORM\PrePersist]
  63.     #[ORM\PreUpdate]
  64.     public function updatedTimestamps(): void
  65.     {
  66.         $this->setUpdateDate(new \DateTime('now'));
  67.         if ($this->getCreateDate() == null) {
  68.             $this->setCreateDate(new \DateTime('now'));
  69.         }
  70.     }
  71.     /**
  72.      * Gets triggered only on insert
  73.      * @ORM\PrePersist
  74.      */
  75.     public function onPrePersist(): void
  76.     {
  77.         $this->createDate = new \DateTime("now");
  78.     }
  79.     /**
  80.      * Gets triggered every time on update
  81.      * @ORM\PreUpdate
  82.      */
  83.     public function onPreUpdate(): void
  84.     {
  85.         $this->updateDate = new \DateTime("now");
  86.     }
  87.     public function getId(): ?int
  88.     {
  89.         return $this->id;
  90.     }
  91.     /**
  92.      * @return int
  93.      */
  94.     public function getYearModel(): int
  95.     {
  96.         return $this->yearModel;
  97.     }
  98.     /**
  99.      * @param int $yearModel
  100.      */
  101.     public function setYearModel(int $yearModel): void
  102.     {
  103.         $this->yearModel $yearModel;
  104.     }
  105.     public function getImageThumbnail(): ?string
  106.     {
  107.         return $this->imageThumbnail;
  108.     }
  109.     public function setImageThumbnail(string $imageThumbnail): self
  110.     {
  111.         $this->imageThumbnail $imageThumbnail;
  112.         return $this;
  113.     }
  114.     public function isNumberCylinder(): ?bool
  115.     {
  116.         return $this->numberCylinder;
  117.     }
  118.     public function setNumberCylinder(bool $numberCylinder): self
  119.     {
  120.         $this->numberCylinder $numberCylinder;
  121.         return $this;
  122.     }
  123.     public function isStatus(): ?bool
  124.     {
  125.         return $this->status;
  126.     }
  127.     public function setStatus(bool $status): self
  128.     {
  129.         $this->status $status;
  130.         return $this;
  131.     }
  132.     public function getCreateDate(): ?\DateTimeInterface
  133.     {
  134.         return $this->createDate;
  135.     }
  136.     public function setCreateDate(\DateTimeInterface $createDate): self
  137.     {
  138.         $this->createDate $createDate;
  139.         return $this;
  140.     }
  141.     public function getUpdateDate(): \DateTimeInterface
  142.     {
  143.         return $this->updateDate;
  144.     }
  145.     public function setUpdateDate(\DateTimeInterface $updateDate): self
  146.     {
  147.         $this->updateDate $updateDate;
  148.         return $this;
  149.     }
  150.     public function getModel(): ?Model
  151.     {
  152.         return $this->model;
  153.     }
  154.     public function setModel(?Model $modelVehicle): self
  155.     {
  156.         $this->model $modelVehicle;
  157.         return $this;
  158.     }
  159.     public function getTransmissionType(): ?TransmissionType
  160.     {
  161.         return $this->transmissionType;
  162.     }
  163.     public function setTransmissionType(?TransmissionType $transmissionType): self
  164.     {
  165.         $this->transmissionType $transmissionType;
  166.         return $this;
  167.     }
  168.     /**
  169.      * @return int
  170.      */
  171.     public function getNumberDoor(): int
  172.     {
  173.         return $this->numberDoor;
  174.     }
  175.     /**
  176.      * @param int $numberDoor
  177.      */
  178.     public function setNumberDoor(int $numberDoor): void
  179.     {
  180.         $this->numberDoor $numberDoor;
  181.     }
  182.     /**
  183.      * @return int
  184.      */
  185.     public function getNumberPassenger(): int
  186.     {
  187.         return $this->numberPassenger;
  188.     }
  189.     /**
  190.      * @param int $numberPassenger
  191.      */
  192.     public function setNumberPassenger(int $numberPassenger): void
  193.     {
  194.         $this->numberPassenger $numberPassenger;
  195.     }
  196.     public function getFuelType(): ?FuelType
  197.     {
  198.         return $this->fuelType;
  199.     }
  200.     public function setFuelType(?FuelType $fuelType): self
  201.     {
  202.         $this->fuelType $fuelType;
  203.         return $this;
  204.     }
  205.     public function getTractionType(): ?TractionType
  206.     {
  207.         return $this->tractionType;
  208.     }
  209.     public function setTractionType(?TractionType $tractionType): self
  210.     {
  211.         $this->tractionType $tractionType;
  212.         return $this;
  213.     }
  214.     /**
  215.      * @return VehicleDirection
  216.      */
  217.     public function getVehicleDirection(): VehicleDirection
  218.     {
  219.         return $this->vehicleDirection;
  220.     }
  221.     /**
  222.      * @param VehicleDirection $vehicleDirection
  223.      */
  224.     public function setVehicleDirection(VehicleDirection $vehicleDirection): void
  225.     {
  226.         $this->vehicleDirection $vehicleDirection;
  227.     }
  228.     public function getCategoriesBlock(): Collection
  229.     {
  230.         return $this->categoriesBlock;
  231.     }
  232. }