23 changed files with 1044 additions and 2 deletions
@ -0,0 +1,7 @@ |
|||||
|
api_platform: |
||||
|
mapping: |
||||
|
paths: ['%kernel.project_dir%/src/Entity'] |
||||
|
patch_formats: |
||||
|
json: ['application/merge-patch+json'] |
||||
|
swagger: |
||||
|
versions: [3] |
@ -0,0 +1,10 @@ |
|||||
|
nelmio_cors: |
||||
|
defaults: |
||||
|
origin_regex: true |
||||
|
allow_origin: ['%env(CORS_ALLOW_ORIGIN)%'] |
||||
|
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE'] |
||||
|
allow_headers: ['Content-Type', 'Authorization'] |
||||
|
expose_headers: ['Link'] |
||||
|
max_age: 3600 |
||||
|
paths: |
||||
|
'^/': null |
@ -0,0 +1,4 @@ |
|||||
|
api_platform: |
||||
|
resource: . |
||||
|
type: api_platform |
||||
|
prefix: /api |
@ -0,0 +1,41 @@ |
|||||
|
<?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 Version20210326134141 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 generation (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); |
||||
|
$this->addSql('CREATE TABLE pokemon (id INT AUTO_INCREMENT NOT NULL, type1_id INT NOT NULL, type2_id INT DEFAULT NULL, generation_id INT NOT NULL, nom VARCHAR(255) NOT NULL, vie INT NOT NULL, attaque INT NOT NULL, defense INT NOT NULL, legendaire TINYINT(1) NOT NULL, INDEX IDX_62DC90F3BFAFA3E1 (type1_id), INDEX IDX_62DC90F3AD1A0C0F (type2_id), INDEX IDX_62DC90F3553A6EC4 (generation_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); |
||||
|
$this->addSql('CREATE TABLE type (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); |
||||
|
$this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3BFAFA3E1 FOREIGN KEY (type1_id) REFERENCES type (id)'); |
||||
|
$this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3AD1A0C0F FOREIGN KEY (type2_id) REFERENCES type (id)'); |
||||
|
$this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3553A6EC4 FOREIGN KEY (generation_id) REFERENCES generation (id)'); |
||||
|
} |
||||
|
|
||||
|
public function down(Schema $schema) : void |
||||
|
{ |
||||
|
// this down() migration is auto-generated, please modify it to your needs |
||||
|
$this->addSql('ALTER TABLE pokemon DROP FOREIGN KEY FK_62DC90F3553A6EC4'); |
||||
|
$this->addSql('ALTER TABLE pokemon DROP FOREIGN KEY FK_62DC90F3BFAFA3E1'); |
||||
|
$this->addSql('ALTER TABLE pokemon DROP FOREIGN KEY FK_62DC90F3AD1A0C0F'); |
||||
|
$this->addSql('DROP TABLE generation'); |
||||
|
$this->addSql('DROP TABLE pokemon'); |
||||
|
$this->addSql('DROP TABLE type'); |
||||
|
} |
||||
|
} |
@ -0,0 +1,45 @@ |
|||||
|
<?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 Version20210326143537 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 pokemon DROP FOREIGN KEY FK_62DC90F3553A6EC4'); |
||||
|
$this->addSql('ALTER TABLE pokemon DROP FOREIGN KEY FK_62DC90F3AD1A0C0F'); |
||||
|
$this->addSql('ALTER TABLE pokemon DROP FOREIGN KEY FK_62DC90F3BFAFA3E1'); |
||||
|
$this->addSql('CREATE TABLE generation_poke (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); |
||||
|
$this->addSql('CREATE TABLE type_poke (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); |
||||
|
$this->addSql('DROP TABLE generation'); |
||||
|
$this->addSql('DROP TABLE pokemon'); |
||||
|
$this->addSql('DROP TABLE type'); |
||||
|
} |
||||
|
|
||||
|
public function down(Schema $schema) : void |
||||
|
{ |
||||
|
// this down() migration is auto-generated, please modify it to your needs |
||||
|
$this->addSql('CREATE TABLE generation (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); |
||||
|
$this->addSql('CREATE TABLE pokemon (id INT AUTO_INCREMENT NOT NULL, type1_id INT NOT NULL, type2_id INT DEFAULT NULL, generation_id INT NOT NULL, nom VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, vie INT NOT NULL, attaque INT NOT NULL, defense INT NOT NULL, legendaire TINYINT(1) NOT NULL, INDEX IDX_62DC90F3553A6EC4 (generation_id), INDEX IDX_62DC90F3BFAFA3E1 (type1_id), INDEX IDX_62DC90F3AD1A0C0F (type2_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); |
||||
|
$this->addSql('CREATE TABLE type (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); |
||||
|
$this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3553A6EC4 FOREIGN KEY (generation_id) REFERENCES generation (id)'); |
||||
|
$this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3AD1A0C0F FOREIGN KEY (type2_id) REFERENCES type (id)'); |
||||
|
$this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3BFAFA3E1 FOREIGN KEY (type1_id) REFERENCES type (id)'); |
||||
|
$this->addSql('DROP TABLE generation_poke'); |
||||
|
$this->addSql('DROP TABLE type_poke'); |
||||
|
} |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
<?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 Version20210326144901 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 pokemon (id INT AUTO_INCREMENT NOT NULL, type1_id INT NOT NULL, type2_id INT DEFAULT NULL, generation_id INT DEFAULT NULL, nom VARCHAR(255) NOT NULL, vie INT NOT NULL, attaque INT NOT NULL, defense INT NOT NULL, legendaire TINYINT(1) NOT NULL, INDEX IDX_62DC90F3BFAFA3E1 (type1_id), INDEX IDX_62DC90F3AD1A0C0F (type2_id), INDEX IDX_62DC90F3553A6EC4 (generation_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); |
||||
|
$this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3BFAFA3E1 FOREIGN KEY (type1_id) REFERENCES type_poke (id)'); |
||||
|
$this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3AD1A0C0F FOREIGN KEY (type2_id) REFERENCES type_poke (id)'); |
||||
|
$this->addSql('ALTER TABLE pokemon ADD CONSTRAINT FK_62DC90F3553A6EC4 FOREIGN KEY (generation_id) REFERENCES generation_poke (id)'); |
||||
|
} |
||||
|
|
||||
|
public function down(Schema $schema) : void |
||||
|
{ |
||||
|
// this down() migration is auto-generated, please modify it to your needs |
||||
|
$this->addSql('DROP TABLE pokemon'); |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
INSERT INTO generation_poke(Id,Name) VALUES (1,'1 Kanto'); |
||||
|
INSERT INTO generation_poke(Id,Name) VALUES (2,'2 Johto'); |
||||
|
INSERT INTO generation_poke(Id,Name) VALUES (3,'3 Hoenn'); |
||||
|
INSERT INTO generation_poke(Id,Name) VALUES (4,'4 Sinnoh'); |
||||
|
INSERT INTO generation_poke(Id,Name) VALUES (5,'5 Unys'); |
||||
|
INSERT INTO generation_poke(Id,Name) VALUES (6,'6 Kalos'); |
||||
|
INSERT INTO generation_poke(Id,Name) VALUES (7,'7 Alola'); |
||||
|
INSERT INTO generation_poke(Id,Name) VALUES (8,'8 Galar'); |
@ -0,0 +1,18 @@ |
|||||
|
INSERT INTO type_poke(Id,Name) VALUES (1,'Bug'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (2,'Dark'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (3,'Dragon'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (4,'Electric'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (5,'Fairy'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (6,'Fighting'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (7,'Fire'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (8,'Flying'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (9,'Ghost'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (10,'Grass'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (11,'Ground'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (12,'Ice'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (13,'Normal'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (14,'Poison'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (15,'Psychic'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (16,'Rock'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (17,'Steel'); |
||||
|
INSERT INTO type_poke(Id,Name) VALUES (18,'Water'); |
@ -0,0 +1,87 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Entity; |
||||
|
|
||||
|
use App\Repository\GenerationPokeRepository; |
||||
|
use Doctrine\Common\Collections\ArrayCollection; |
||||
|
use Doctrine\Common\Collections\Collection; |
||||
|
use Doctrine\ORM\Mapping as ORM; |
||||
|
use ApiPlatform\Core\Annotation\ApiResource; |
||||
|
use Symfony\Component\Serializer\Annotation\Groups; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\Entity(repositoryClass=GenerationPokeRepository::class) |
||||
|
* @ApiResource |
||||
|
*/ |
||||
|
class GenerationPoke |
||||
|
{ |
||||
|
/** |
||||
|
* @ORM\Id |
||||
|
* @ORM\GeneratedValue |
||||
|
* @ORM\Column(type="integer") |
||||
|
*/ |
||||
|
private $id; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\Column(type="string", length=255) |
||||
|
* @Groups({"pokemon_read"}) |
||||
|
*/ |
||||
|
private $name; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\OneToMany(targetEntity=Pokemon::class, mappedBy="generation") |
||||
|
*/ |
||||
|
private $pokemon; |
||||
|
|
||||
|
public function __construct() |
||||
|
{ |
||||
|
$this->pokemon = new ArrayCollection(); |
||||
|
} |
||||
|
|
||||
|
public function getId(): ?int |
||||
|
{ |
||||
|
return $this->id; |
||||
|
} |
||||
|
|
||||
|
public function getName(): ?string |
||||
|
{ |
||||
|
return $this->name; |
||||
|
} |
||||
|
|
||||
|
public function setName(string $name): self |
||||
|
{ |
||||
|
$this->name = $name; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return Collection|Pokemon[] |
||||
|
*/ |
||||
|
public function getPokemon(): Collection |
||||
|
{ |
||||
|
return $this->pokemon; |
||||
|
} |
||||
|
|
||||
|
public function addPokemon(Pokemon $pokemon): self |
||||
|
{ |
||||
|
if (!$this->pokemon->contains($pokemon)) { |
||||
|
$this->pokemon[] = $pokemon; |
||||
|
$pokemon->setGeneration($this); |
||||
|
} |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function removePokemon(Pokemon $pokemon): self |
||||
|
{ |
||||
|
if ($this->pokemon->removeElement($pokemon)) { |
||||
|
// set the owning side to null (unless already changed) |
||||
|
if ($pokemon->getGeneration() === $this) { |
||||
|
$pokemon->setGeneration(null); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
} |
@ -0,0 +1,177 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Entity; |
||||
|
|
||||
|
use App\Repository\PokemonRepository; |
||||
|
use Doctrine\ORM\Mapping as ORM; |
||||
|
use ApiPlatform\Core\Annotation\ApiResource; |
||||
|
use Symfony\Component\Serializer\Annotation\Groups; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\Entity(repositoryClass=PokemonRepository::class) |
||||
|
* @ApiResource( |
||||
|
* normalizationContext={ |
||||
|
* "groups"={"pokemon_read"} |
||||
|
* } |
||||
|
* ) |
||||
|
*/ |
||||
|
class Pokemon |
||||
|
{ |
||||
|
/** |
||||
|
* @ORM\Id |
||||
|
* @ORM\GeneratedValue |
||||
|
* @ORM\Column(type="integer") |
||||
|
* @Groups({"pokemon_read"}) |
||||
|
*/ |
||||
|
private $id; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\Column(type="string", length=255) |
||||
|
* @Groups({"pokemon_read"}) |
||||
|
*/ |
||||
|
private $nom; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\ManyToOne(targetEntity=TypePoke::class, inversedBy="pokemon") |
||||
|
* @ORM\JoinColumn(nullable=false) |
||||
|
* @Groups({"pokemon_read"}) |
||||
|
*/ |
||||
|
private $type1; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\ManyToOne(targetEntity=TypePoke::class) |
||||
|
* @Groups({"pokemon_read"}) |
||||
|
*/ |
||||
|
private $type2; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\Column(type="integer") |
||||
|
* @Groups({"pokemon_read"}) |
||||
|
*/ |
||||
|
private $vie; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\Column(type="integer") |
||||
|
* @Groups({"pokemon_read"}) |
||||
|
*/ |
||||
|
private $attaque; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\Column(type="integer") |
||||
|
* @Groups({"pokemon_read"}) |
||||
|
*/ |
||||
|
private $defense; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\Column(type="boolean") |
||||
|
* @Groups({"pokemon_read"}) |
||||
|
*/ |
||||
|
private $legendaire; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\ManyToOne(targetEntity=GenerationPoke::class, inversedBy="pokemon") |
||||
|
* @Groups({"pokemon_read"}) |
||||
|
*/ |
||||
|
private $generation; |
||||
|
|
||||
|
public function getId(): ?int |
||||
|
{ |
||||
|
return $this->id; |
||||
|
} |
||||
|
|
||||
|
public function getNom(): ?string |
||||
|
{ |
||||
|
return $this->nom; |
||||
|
} |
||||
|
|
||||
|
public function setNom(string $nom): self |
||||
|
{ |
||||
|
$this->nom = $nom; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getType1(): ?TypePoke |
||||
|
{ |
||||
|
return $this->type1; |
||||
|
} |
||||
|
|
||||
|
public function setType1(?TypePoke $type1): self |
||||
|
{ |
||||
|
$this->type1 = $type1; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getType2(): ?TypePoke |
||||
|
{ |
||||
|
return $this->type2; |
||||
|
} |
||||
|
|
||||
|
public function setType2(?TypePoke $type2): self |
||||
|
{ |
||||
|
$this->type2 = $type2; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getVie(): ?int |
||||
|
{ |
||||
|
return $this->vie; |
||||
|
} |
||||
|
|
||||
|
public function setVie(int $vie): self |
||||
|
{ |
||||
|
$this->vie = $vie; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getAttaque(): ?int |
||||
|
{ |
||||
|
return $this->attaque; |
||||
|
} |
||||
|
|
||||
|
public function setAttaque(int $attaque): self |
||||
|
{ |
||||
|
$this->attaque = $attaque; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getDefense(): ?int |
||||
|
{ |
||||
|
return $this->defense; |
||||
|
} |
||||
|
|
||||
|
public function setDefense(int $defense): self |
||||
|
{ |
||||
|
$this->defense = $defense; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getLegendaire(): ?bool |
||||
|
{ |
||||
|
return $this->legendaire; |
||||
|
} |
||||
|
|
||||
|
public function setLegendaire(bool $legendaire): self |
||||
|
{ |
||||
|
$this->legendaire = $legendaire; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getGeneration(): ?GenerationPoke |
||||
|
{ |
||||
|
return $this->generation; |
||||
|
} |
||||
|
|
||||
|
public function setGeneration(?GenerationPoke $generation): self |
||||
|
{ |
||||
|
$this->generation = $generation; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
} |
@ -0,0 +1,91 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Entity; |
||||
|
|
||||
|
use App\Repository\TypePokeRepository; |
||||
|
use Doctrine\Common\Collections\ArrayCollection; |
||||
|
use Doctrine\Common\Collections\Collection; |
||||
|
use Doctrine\ORM\Mapping as ORM; |
||||
|
use ApiPlatform\Core\Annotation\ApiResource; |
||||
|
use Symfony\Component\Serializer\Annotation\Groups; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\Entity(repositoryClass=TypePokeRepository::class) |
||||
|
* @ApiResource( |
||||
|
* normalizationContext={ |
||||
|
* "groups"={"pokemon_read"} |
||||
|
* } |
||||
|
* ) |
||||
|
*/ |
||||
|
class TypePoke |
||||
|
{ |
||||
|
/** |
||||
|
* @ORM\Id |
||||
|
* @ORM\GeneratedValue |
||||
|
* @ORM\Column(type="integer") |
||||
|
*/ |
||||
|
private $id; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\Column(type="string", length=255) |
||||
|
* @Groups({"pokemon_read"}) |
||||
|
*/ |
||||
|
private $name; |
||||
|
|
||||
|
/** |
||||
|
* @ORM\OneToMany(targetEntity=Pokemon::class, mappedBy="type1") |
||||
|
*/ |
||||
|
private $pokemon; |
||||
|
|
||||
|
public function __construct() |
||||
|
{ |
||||
|
$this->pokemon = new ArrayCollection(); |
||||
|
} |
||||
|
|
||||
|
public function getId(): ?int |
||||
|
{ |
||||
|
return $this->id; |
||||
|
} |
||||
|
|
||||
|
public function getName(): ?string |
||||
|
{ |
||||
|
return $this->name; |
||||
|
} |
||||
|
|
||||
|
public function setName(string $name): self |
||||
|
{ |
||||
|
$this->name = $name; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return Collection|Pokemon[] |
||||
|
*/ |
||||
|
public function getPokemon(): Collection |
||||
|
{ |
||||
|
return $this->pokemon; |
||||
|
} |
||||
|
|
||||
|
public function addPokemon(Pokemon $pokemon): self |
||||
|
{ |
||||
|
if (!$this->pokemon->contains($pokemon)) { |
||||
|
$this->pokemon[] = $pokemon; |
||||
|
$pokemon->setType1($this); |
||||
|
} |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function removePokemon(Pokemon $pokemon): self |
||||
|
{ |
||||
|
if ($this->pokemon->removeElement($pokemon)) { |
||||
|
// set the owning side to null (unless already changed) |
||||
|
if ($pokemon->getType1() === $this) { |
||||
|
$pokemon->setType1(null); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
} |
@ -0,0 +1,50 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Repository; |
||||
|
|
||||
|
use App\Entity\GenerationPoke; |
||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
||||
|
use Doctrine\Persistence\ManagerRegistry; |
||||
|
|
||||
|
/** |
||||
|
* @method GenerationPoke|null find($id, $lockMode = null, $lockVersion = null) |
||||
|
* @method GenerationPoke|null findOneBy(array $criteria, array $orderBy = null) |
||||
|
* @method GenerationPoke[] findAll() |
||||
|
* @method GenerationPoke[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
||||
|
*/ |
||||
|
class GenerationPokeRepository extends ServiceEntityRepository |
||||
|
{ |
||||
|
public function __construct(ManagerRegistry $registry) |
||||
|
{ |
||||
|
parent::__construct($registry, GenerationPoke::class); |
||||
|
} |
||||
|
|
||||
|
// /** |
||||
|
// * @return GenerationPoke[] Returns an array of GenerationPoke objects |
||||
|
// */ |
||||
|
/* |
||||
|
public function findByExampleField($value) |
||||
|
{ |
||||
|
return $this->createQueryBuilder('g') |
||||
|
->andWhere('g.exampleField = :val') |
||||
|
->setParameter('val', $value) |
||||
|
->orderBy('g.id', 'ASC') |
||||
|
->setMaxResults(10) |
||||
|
->getQuery() |
||||
|
->getResult() |
||||
|
; |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
/* |
||||
|
public function findOneBySomeField($value): ?GenerationPoke |
||||
|
{ |
||||
|
return $this->createQueryBuilder('g') |
||||
|
->andWhere('g.exampleField = :val') |
||||
|
->setParameter('val', $value) |
||||
|
->getQuery() |
||||
|
->getOneOrNullResult() |
||||
|
; |
||||
|
} |
||||
|
*/ |
||||
|
} |
@ -0,0 +1,50 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Repository; |
||||
|
|
||||
|
use App\Entity\Pokemon; |
||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
||||
|
use Doctrine\Persistence\ManagerRegistry; |
||||
|
|
||||
|
/** |
||||
|
* @method Pokemon|null find($id, $lockMode = null, $lockVersion = null) |
||||
|
* @method Pokemon|null findOneBy(array $criteria, array $orderBy = null) |
||||
|
* @method Pokemon[] findAll() |
||||
|
* @method Pokemon[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
||||
|
*/ |
||||
|
class PokemonRepository extends ServiceEntityRepository |
||||
|
{ |
||||
|
public function __construct(ManagerRegistry $registry) |
||||
|
{ |
||||
|
parent::__construct($registry, Pokemon::class); |
||||
|
} |
||||
|
|
||||
|
// /** |
||||
|
// * @return Pokemon[] Returns an array of Pokemon objects |
||||
|
// */ |
||||
|
/* |
||||
|
public function findByExampleField($value) |
||||
|
{ |
||||
|
return $this->createQueryBuilder('p') |
||||
|
->andWhere('p.exampleField = :val') |
||||
|
->setParameter('val', $value) |
||||
|
->orderBy('p.id', 'ASC') |
||||
|
->setMaxResults(10) |
||||
|
->getQuery() |
||||
|
->getResult() |
||||
|
; |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
/* |
||||
|
public function findOneBySomeField($value): ?Pokemon |
||||
|
{ |
||||
|
return $this->createQueryBuilder('p') |
||||
|
->andWhere('p.exampleField = :val') |
||||
|
->setParameter('val', $value) |
||||
|
->getQuery() |
||||
|
->getOneOrNullResult() |
||||
|
; |
||||
|
} |
||||
|
*/ |
||||
|
} |
@ -0,0 +1,50 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Repository; |
||||
|
|
||||
|
use App\Entity\TypePoke; |
||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
||||
|
use Doctrine\Persistence\ManagerRegistry; |
||||
|
|
||||
|
/** |
||||
|
* @method TypePoke|null find($id, $lockMode = null, $lockVersion = null) |
||||
|
* @method TypePoke|null findOneBy(array $criteria, array $orderBy = null) |
||||
|
* @method TypePoke[] findAll() |
||||
|
* @method TypePoke[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
||||
|
*/ |
||||
|
class TypePokeRepository extends ServiceEntityRepository |
||||
|
{ |
||||
|
public function __construct(ManagerRegistry $registry) |
||||
|
{ |
||||
|
parent::__construct($registry, TypePoke::class); |
||||
|
} |
||||
|
|
||||
|
// /** |
||||
|
// * @return TypePoke[] Returns an array of TypePoke objects |
||||
|
// */ |
||||
|
/* |
||||
|
public function findByExampleField($value) |
||||
|
{ |
||||
|
return $this->createQueryBuilder('t') |
||||
|
->andWhere('t.exampleField = :val') |
||||
|
->setParameter('val', $value) |
||||
|
->orderBy('t.id', 'ASC') |
||||
|
->setMaxResults(10) |
||||
|
->getQuery() |
||||
|
->getResult() |
||||
|
; |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
/* |
||||
|
public function findOneBySomeField($value): ?TypePoke |
||||
|
{ |
||||
|
return $this->createQueryBuilder('t') |
||||
|
->andWhere('t.exampleField = :val') |
||||
|
->setParameter('val', $value) |
||||
|
->getQuery() |
||||
|
->getOneOrNullResult() |
||||
|
; |
||||
|
} |
||||
|
*/ |
||||
|
} |
Loading…
Reference in new issue