<?php
namespace App\Entity;
use App\Repository\OpenPortRepository;
use Doctrine\ORM\Mapping as ORM;
use App\Traits\DateTimeTrait;
use Overblog\GraphQLBundle\Annotation\Field;
use Doctrine\Common\Collections\Collection;
use App\Attribute\Searchable;
use DateTimeImmutable;
#[ORM\Entity(repositoryClass: OpenPortRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[UniqueEntity(
fields: ['exposed_ip', 'port'],
message: 'This port is already in use on that IP.',
errorPath: 'port',
)]
#[ORM\UniqueConstraint(name: 'unique_exposed_ip_port', columns: ['exposed_ip_id', 'port'])]
class OpenPort extends BasicEntity
{
use DateTimeTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: "integer")]
#[Field(name: "id", type: "int")]
private $id;
#[ORM\Column(type: "integer")]
#[Field(name: "port", type: "int")]
#[Searchable(name: 'port')]
private $port;
#[ORM\ManyToOne(inversedBy: 'openPorts', targetEntity: ExposedIp::class, cascade: ['persist', 'remove'])]
#[Field(name: "exposed_ip", nullable: false)]
private $exposedIp;
#[ORM\Column(type: "boolean", options: ['default' => true])]
#[Field(name: "is_active", type: "boolean")]
private $isActive;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
#[Field(name: "last_seen", type: "string")]
private $lastSeen;
#[ORM\ManyToOne(targetEntity: Status::class, inversedBy: 'exposedIps')]
#[ORM\JoinColumn(nullable: true, options: ['default' => 1])]
#[Field(name: "status")]
private $status;
public function getId(): ?int
{
return $this->id;
}
public function getPort(): ?int
{
return $this->port;
}
public function setPort(int $port): self
{
$this->port = $port;
return $this;
}
/**
* @return ExposedIp
*/
public function getExposedIp(): ExposedIp
{
return $this->exposedIp;
}
public function setExposedIp(ExposedIp $exposedIp): self
{
$this->$exposedIp = $exposedIp;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(?bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getLastSeen(): ?DateTimeImmutable
{
return $this->lastSeen;
}
public function setLastSeen(?DateTimeImmutable $lastSeen): self
{
$this->lastSeen = $lastSeen;
return $this;
}
public function getStatus(): ?Status
{
return $this->status;
}
public function setStatus(?Status $status): self
{
$this->status = $status;
return $this;
}
}