add db and fixtures

This commit is contained in:
Tykayn 2025-05-26 11:32:53 +02:00 committed by tykayn
parent 03f53f4688
commit 528ebb672a
20 changed files with 1655 additions and 116 deletions

71
src/Entity/History.php Normal file
View file

@ -0,0 +1,71 @@
<?php
namespace App\Entity;
use App\Repository\HistoryRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: HistoryRepository::class)]
class History
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: Types::SMALLINT, nullable: true)]
private ?int $completion_percent = null;
#[ORM\Column]
private ?\DateTime $date_time = null;
#[ORM\ManyToOne(inversedBy: 'histories')]
#[ORM\JoinColumn(nullable: false)]
private ?Place $place_id = null;
public function getId(): ?int
{
return $this->id;
}
public function getCompletionPercent(): ?int
{
return $this->completion_percent;
}
public function setCompletionPercent(?int $completion_percent): static
{
$this->completion_percent = $completion_percent;
return $this;
}
public function getDateTime(): ?\DateTime
{
return $this->date_time;
}
public function setDateTime(\DateTime $date_time): static
{
$this->date_time = $date_time;
return $this;
}
public function getPlaceId(): ?Place
{
return $this->place_id;
}
public function setPlaceId(?Place $place_id): static
{
$this->place_id = $place_id;
return $this;
}
}

259
src/Entity/Place.php Normal file
View file

@ -0,0 +1,259 @@
<?php
namespace App\Entity;
use App\Repository\PlaceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PlaceRepository::class)]
class Place
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 50)]
private ?string $uuid_for_url = null;
#[ORM\Column(length: 10)]
private ?string $osm_kind = null;
#[ORM\Column(length: 255)]
private ?string $email = null;
#[ORM\Column]
private ?bool $opted_out = null;
#[ORM\Column]
private ?bool $dead = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $note = null;
#[ORM\Column(nullable: true)]
private ?\DateTime $modified_date = null;
#[ORM\Column(type: Types::INTEGER)]
private ?int $zip_code = null;
#[ORM\Column]
private ?bool $asked_humains_support = null;
#[ORM\Column(nullable: true)]
private ?\DateTime $last_contact_attempt_date = null;
/**
* @var Collection<int, History>
*/
#[ORM\OneToMany(targetEntity: History::class, mappedBy: 'place_id', orphanRemoval: true)]
private Collection $histories;
#[ORM\ManyToOne(inversedBy: 'places')]
private ?Stats $stats = null;
#[ORM\Column(type: Types::BIGINT)]
private ?string $osmId = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
public function __construct()
{
$this->histories = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUuidForUrl(): ?string
{
return $this->uuid_for_url;
}
public function setUuidForUrl(string $uuid_for_url): static
{
$this->uuid_for_url = $uuid_for_url;
return $this;
}
public function getOsmKind(): ?string
{
return $this->osm_kind;
}
public function setOsmKind(string $osm_kind): static
{
$this->osm_kind = $osm_kind;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): static
{
$this->email = $email;
return $this;
}
public function isOptedOut(): ?bool
{
return $this->opted_out;
}
public function setOptedOut(bool $opted_out): static
{
$this->opted_out = $opted_out;
return $this;
}
public function isDead(): ?bool
{
return $this->dead;
}
public function setDead(bool $dead): static
{
$this->dead = $dead;
return $this;
}
public function getNote(): ?string
{
return $this->note;
}
public function setNote(?string $note): static
{
$this->note = $note;
return $this;
}
public function getModifiedDate(): ?\DateTime
{
return $this->modified_date;
}
public function setModifiedDate(?\DateTime $modified_date): static
{
$this->modified_date = $modified_date;
return $this;
}
public function getZipCode(): ?int
{
return $this->zip_code;
}
public function setZipCode(int $zip_code): static
{
$this->zip_code = $zip_code;
return $this;
}
public function isAskedHumainsSupport(): ?bool
{
return $this->asked_humains_support;
}
public function setAskedHumainsSupport(bool $asked_humains_support): static
{
$this->asked_humains_support = $asked_humains_support;
return $this;
}
public function getLastContactAttemptDate(): ?\DateTime
{
return $this->last_contact_attempt_date;
}
public function setLastContactAttemptDate(?\DateTime $last_contact_attempt_date): static
{
$this->last_contact_attempt_date = $last_contact_attempt_date;
return $this;
}
/**
* @return Collection<int, History>
*/
public function getHistories(): Collection
{
return $this->histories;
}
public function addHistory(History $history): static
{
if (!$this->histories->contains($history)) {
$this->histories->add($history);
$history->setPlaceId($this);
}
return $this;
}
public function removeHistory(History $history): static
{
if ($this->histories->removeElement($history)) {
// set the owning side to null (unless already changed)
if ($history->getPlaceId() === $this) {
$history->setPlaceId(null);
}
}
return $this;
}
public function getStats(): ?Stats
{
return $this->stats;
}
public function setStats(?Stats $stats): static
{
$this->stats = $stats;
return $this;
}
public function getOsmId(): ?string
{
return $this->osmId;
}
public function setOsmId(string $osmId): static
{
$this->osmId = $osmId;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
}

109
src/Entity/Stats.php Normal file
View file

@ -0,0 +1,109 @@
<?php
namespace App\Entity;
use App\Repository\StatsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: StatsRepository::class)]
class Stats
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $zone = null;
#[ORM\Column(type: Types::SMALLINT)]
private ?int $completion_percent = null;
/**
* @var Collection<int, Place>
*/
#[ORM\OneToMany(targetEntity: Place::class, mappedBy: 'stats')]
private Collection $places;
#[ORM\Column(type: Types::SMALLINT)]
private ?int $places_count = null;
public function __construct()
{
$this->places = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getZone(): ?string
{
return $this->zone;
}
public function setZone(string $zone): static
{
$this->zone = $zone;
return $this;
}
public function getCompletionPercent(): ?int
{
return $this->completion_percent;
}
public function setCompletionPercent(int $completion_percent): static
{
$this->completion_percent = $completion_percent;
return $this;
}
/**
* @return Collection<int, Place>
*/
public function getPlaces(): Collection
{
return $this->places;
}
public function addPlace(Place $place): static
{
if (!$this->places->contains($place)) {
$this->places->add($place);
$place->setStats($this);
}
return $this;
}
public function removePlace(Place $place): static
{
if ($this->places->removeElement($place)) {
// set the owning side to null (unless already changed)
if ($place->getStats() === $this) {
$place->setStats(null);
}
}
return $this;
}
public function getPlacesCount(): ?int
{
return $this->places_count;
}
public function setPlacesCount(int $places_count): static
{
$this->places_count = $places_count;
return $this;
}
}