123
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20241211060919 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE TABLE ancestry (id VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, rarity INT NOT NULL, type VARCHAR(255) NOT NULL, attribute JSON DEFAULT NULL, attribute_flaw JSON DEFAULT NULL, hp_raw INT DEFAULT NULL, image JSON DEFAULT NULL, size JSON NOT NULL, speed VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('DROP TABLE ancestry');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20241211061051 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE ancestry ADD item_id INT NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE ancestry ADD CONSTRAINT FK_63FAD02F126F525E FOREIGN KEY (item_id) REFERENCES item (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_63FAD02F126F525E ON ancestry (item_id)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('ALTER TABLE ancestry DROP CONSTRAINT FK_63FAD02F126F525E');
|
||||||
|
$this->addSql('DROP INDEX UNIQ_63FAD02F126F525E');
|
||||||
|
$this->addSql('ALTER TABLE ancestry DROP item_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20241211061203 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE ancestry ALTER hp_raw TYPE VARCHAR(255)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('ALTER TABLE ancestry ALTER hp_raw TYPE INT');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,14 +37,24 @@ return [
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
"ancestry" => [
|
"ancestry" => [
|
||||||
// "class" => ,
|
"class" => \App\Entity\Pf2e\Ancestry::class,
|
||||||
"schema" => [
|
"schema" => [
|
||||||
|
"name" => true,
|
||||||
"rarity" => [
|
"rarity" => [
|
||||||
"method" => "enum",
|
"method" => "enum",
|
||||||
"field" => "rarity_id",
|
"field" => "rarity_id",
|
||||||
"enum" => \App\Entity\Rarity::class,
|
"enum" => \App\Entity\Rarity::class,
|
||||||
],
|
],
|
||||||
|
"type" => true,
|
||||||
|
"attribute" => true,
|
||||||
|
"attribute_flaw" => true,
|
||||||
|
"hp_raw" => true,
|
||||||
|
"image" => true,
|
||||||
|
"size" => true,
|
||||||
|
"speed" => "speed_markdown",
|
||||||
|
|
||||||
|
// "trait" => [],
|
||||||
|
// "source" => [],
|
||||||
],
|
],
|
||||||
"localization" => [
|
"localization" => [
|
||||||
"title" => "name",
|
"title" => "name",
|
||||||
|
|||||||
@@ -0,0 +1,179 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity\Pf2e;
|
||||||
|
|
||||||
|
use App\Entity\Item;
|
||||||
|
use App\Entity\Rarity;
|
||||||
|
use App\Repository\Pf2e\AncestryRepository;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: AncestryRepository::class)]
|
||||||
|
class Ancestry
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?string $id = null;
|
||||||
|
|
||||||
|
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
|
||||||
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
private ?Item $item = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $name = null;
|
||||||
|
|
||||||
|
#[ORM\Column(enumType: Rarity::class)]
|
||||||
|
private ?Rarity $rarity = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $type = null;
|
||||||
|
|
||||||
|
#[ORM\Column(nullable: true)]
|
||||||
|
private ?array $attribute = null;
|
||||||
|
|
||||||
|
#[ORM\Column(nullable: true)]
|
||||||
|
private ?array $attribute_flaw = null;
|
||||||
|
|
||||||
|
#[ORM\Column(nullable: true)]
|
||||||
|
private ?string $hp_raw = null;
|
||||||
|
|
||||||
|
#[ORM\Column(nullable: true)]
|
||||||
|
private ?array $image = null;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private array $size = [];
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $speed = null;
|
||||||
|
|
||||||
|
public function getId(): ?string
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setId(string $value): self
|
||||||
|
{
|
||||||
|
$this->id = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getItem(): ?Item
|
||||||
|
{
|
||||||
|
return $this->item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setItem(Item $item): static
|
||||||
|
{
|
||||||
|
$this->item = $item;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): ?string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(string $name): static
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRarity(): ?Rarity
|
||||||
|
{
|
||||||
|
return $this->rarity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setRarity(Rarity $rarity): static
|
||||||
|
{
|
||||||
|
$this->rarity = $rarity;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getType(): ?string
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setType(string $type): static
|
||||||
|
{
|
||||||
|
$this->type = $type;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttribute(): ?array
|
||||||
|
{
|
||||||
|
return $this->attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAttribute(?array $attribute): static
|
||||||
|
{
|
||||||
|
$this->attribute = $attribute;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeFlaw(): ?array
|
||||||
|
{
|
||||||
|
return $this->attribute_flaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAttributeFlaw(?array $attribute_flaw): static
|
||||||
|
{
|
||||||
|
$this->attribute_flaw = $attribute_flaw;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHpRaw(): ?string
|
||||||
|
{
|
||||||
|
return $this->hp_raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHpRaw(?string $hp_raw): static
|
||||||
|
{
|
||||||
|
$this->hp_raw = $hp_raw;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getImage(): ?array
|
||||||
|
{
|
||||||
|
return $this->image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setImage(?array $image): static
|
||||||
|
{
|
||||||
|
$this->image = $image;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSize(): array
|
||||||
|
{
|
||||||
|
return $this->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSize(array $size): static
|
||||||
|
{
|
||||||
|
$this->size = $size;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSpeed(): ?string
|
||||||
|
{
|
||||||
|
return $this->speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSpeed(string $speed): static
|
||||||
|
{
|
||||||
|
$this->speed = $speed;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository\Pf2e;
|
||||||
|
|
||||||
|
use App\Entity\Pf2e\Ancestry;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<Ancestry>
|
||||||
|
*/
|
||||||
|
class AncestryRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, Ancestry::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @return Ancestry[] Returns an array of Ancestry objects
|
||||||
|
// */
|
||||||
|
// public function findByExampleField($value): array
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('a')
|
||||||
|
// ->andWhere('a.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->orderBy('a.id', 'ASC')
|
||||||
|
// ->setMaxResults(10)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function findOneBySomeField($value): ?Ancestry
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('a')
|
||||||
|
// ->andWhere('a.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getOneOrNullResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user