<?phpnamespace App\Entity\Forum;use Doctrine\ORM\Mapping as ORM;use App\Traits\CreatedUpdatedTrait;use Gedmo\Mapping\Annotation as Gedmo;use JMS\Serializer\Annotation\Exclude;use JMS\Serializer\Annotation as JMS;use Symfony\Component\HttpFoundation\File\File;use Vich\UploaderBundle\Mapping\Annotation as Vich;/** * @ORM\Table(name="v_forum_post_reply") * @ORM\Entity(repositoryClass="App\Repository\Forum\PostReplyRepository") * @Vich\Uploadable * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false) */class PostReply{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\ManyToOne(targetEntity="App\Entity\Forum\Post") * @Exclude */ private $post; /** * @ORM\ManyToOne(targetEntity="App\Entity\User") * @Exclude */ private $user; /** * @ORM\ManyToOne(targetEntity="App\Entity\Admin") * @Exclude */ private $admin; /** * @ORM\ManyToOne(targetEntity="App\Entity\Forum\PostReply") * @Exclude */ private $reply; /** * @ORM\Column(type="text") */ private $message; /** * NOTE: This is not a mapped field of entity metadata, just a simple property. * * @Vich\UploadableField(mapping="forum_files", fileNameProperty="image") * * @var File * @Exclude */ private $imageFile; /** * @ORM\Column(name="image", type="string", length=255, nullable=true) * * @var string */ private $image; /** * @ORM\Column(type="boolean") */ private $banned = false; /** * @ORM\Column(name="deleted_at", type="datetime", nullable=true) */ private $deletedAt; use CreatedUpdatedTrait; public function __toString() { return $this->message; } public function getId(): ?int { return $this->id; } /** * @return mixed */ public function getPost() { return $this->post; } /** * @param mixed $post */ public function setPost($post): void { $this->post = $post; } /** * @return mixed */ public function getUser() { return $this->user; } /** * @param mixed $user */ public function setUser($user): void { $this->user = $user; } /** * @return mixed */ public function getAdmin() { return $this->admin; } /** * @param mixed $admin */ public function setAdmin($admin): void { $this->admin = $admin; } /** * @return mixed */ public function getReply() { return $this->reply; } /** * @param mixed $reply */ public function setReply($reply): void { $this->reply = $reply; } /** * @return mixed */ public function getMessage() { return $this->message; } /** * @param mixed $message */ public function setMessage($message): void { $this->message = $message; } /** * @JMS\VirtualProperty * @JMS\SerializedName("user_id") * * @return string */ public function getUserId() { return $this->getUser() ? $this->getUser()->getId() : 0; } /** * @JMS\VirtualProperty * @JMS\SerializedName("user_name") * * @return string */ public function getUserName() { if($this->getUser()){ return $this->getUser()->getName(); }elseif($this->getAdmin()){ return 'IdealOfMed'; }else{ return ''; } } /** * If manually uploading a file (i.e. not using Symfony Form) ensure an instance * of 'UploadedFile' is injected into this setter to trigger the update. If this * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter * must be able to accept an instance of 'File' as the bundle will inject one here * during Doctrine hydration. * * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $file */ public function setImageFile(File $file = null) { $this->imageFile = $file; if ($file) { // It is required that at least one field changes if you are using doctrine // otherwise the event listeners won't be called and the file is lost $this->updated = new \DateTime('now'); } } /** * @return File */ public function getImageFile() { return $this->imageFile; } /** * @param string $image */ public function setImage($image) { $this->image = $image; } /** * @return string */ public function getImage() { return $this->image; } /** * @return bool */ public function isBanned(): ?bool { return $this->banned; } /** * @param bool $banned */ public function setBanned(?bool $banned): void { $this->banned = $banned; } /** * @return mixed */ public function getDeletedAt() { return $this->deletedAt; } /** * @param mixed $deletedAt */ public function setDeletedAt($deletedAt): void { $this->deletedAt = $deletedAt; }}