Created
March 15, 2019 13:41
-
-
Save r8or0pz/98de2e3c3a5ec858f09fd243cfa7a745 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Entity; | |
use Doctrine\Common\Collections\ArrayCollection; | |
use Doctrine\Common\Collections\Collection; | |
use Doctrine\ORM\Mapping as ORM; | |
use Symfony\Component\Validator\Constraints as Assert; | |
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; | |
/** | |
* @ORM\Entity(repositoryClass="App\Repository\VehicleRegisteredTypeRepository") | |
* @ORM\HasLifecycleCallbacks | |
* @UniqueEntity("name") | |
*/ | |
class VehicleRegisteredType implements iUploadable | |
{ | |
use UploadableTrait; | |
use TimestampableTrait; | |
const BUCKET_PREFIX = 'aws.s3.vehicle_registered_type_image_bucket_prefix'; | |
/** | |
* @ORM\Id() | |
* @ORM\GeneratedValue() | |
* @ORM\Column(type="integer") | |
*/ | |
private $id; | |
/** | |
* @ORM\ManyToOne(targetEntity="VehicleType", inversedBy="registeredVehicleTypes") | |
*/ | |
private $vehicleType; | |
/** | |
* @ORM\Column(type="string", length=255, unique=true) | |
* @Assert\NotBlank | |
*/ | |
private $name; | |
/** | |
* @ORM\Column(type="text", nullable=true) | |
*/ | |
private $description; | |
/** | |
* @ORM\Column(type="integer", nullable=true) | |
* @Assert\NotBlank | |
*/ | |
private $prescheduling_time; | |
/** | |
* @ORM\Column(type="integer", nullable=true) | |
* @Assert\NotBlank | |
*/ | |
private $passengers; | |
/** | |
* @ORM\Column(type="integer", nullable=true) | |
* @Assert\NotBlank | |
*/ | |
private $luggage; | |
/** | |
* @ORM\ManyToMany(targetEntity="VehicleRegisteredType") | |
* @ORM\JoinTable(name="vehicle_registered_type_map", | |
* inverseJoinColumns={@ORM\JoinColumn(name="related_id", referencedColumnName="id")} | |
* ) | |
*/ | |
private $map; | |
public function __construct() | |
{ | |
$this->map = new ArrayCollection(); | |
} | |
public function getId(): ?int | |
{ | |
return $this->id; | |
} | |
public function getVehicleType(): ?VehicleType | |
{ | |
return $this->vehicleType; | |
} | |
public function setVehicleType(?VehicleType $vehicleType): self | |
{ | |
$this->vehicleType = $vehicleType; | |
return $this; | |
} | |
public function getName(): ?string | |
{ | |
return $this->name; | |
} | |
public function setName(string $name): self | |
{ | |
$this->name = $name; | |
return $this; | |
} | |
public function getDescription(): ?string | |
{ | |
return $this->description; | |
} | |
public function setDescription(?string $description): self | |
{ | |
$this->description = $description; | |
return $this; | |
} | |
public function getPreschedulingTime(): ?int | |
{ | |
return $this->prescheduling_time; | |
} | |
public function setPreschedulingTime(?int $prescheduling_time): self | |
{ | |
$this->prescheduling_time = $prescheduling_time; | |
return $this; | |
} | |
public function getPassengers(): ?int | |
{ | |
return $this->passengers; | |
} | |
public function setPassengers(?int $passengers): self | |
{ | |
$this->passengers = $passengers; | |
return $this; | |
} | |
public function getLuggage(): ?int | |
{ | |
return $this->luggage; | |
} | |
public function setLuggage(?int $luggage): self | |
{ | |
$this->luggage = $luggage; | |
return $this; | |
} | |
/** | |
* @return Collection|self[] | |
*/ | |
public function getMap(): Collection | |
{ | |
return $this->map; | |
} | |
public function addMap(self $map): self | |
{ | |
if (!$this->map->contains($map)) { | |
$this->map[] = $map; | |
} | |
return $this; | |
} | |
public function removeMap(self $map): self | |
{ | |
if ($this->map->contains($map)) { | |
$this->map->removeElement($map); | |
} | |
return $this; | |
} | |
public function __clone() { | |
$this->id = null; | |
$this->setName('Copy of '.$this->getName()); | |
// replacing image URI back to filename | |
$this->resetImage(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment