You've already forked symfony-playground
product as OneToOne
This commit is contained in:
@ -6,7 +6,7 @@ use App\Repository\MerBeDMRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: MerBeDMRepository::class)]
|
||||
class MerBeDM extends MerService
|
||||
class MerBeDM extends MerService implements OttInterface
|
||||
{
|
||||
// #[ORM\Id]
|
||||
// #[ORM\GeneratedValue]
|
||||
@ -16,10 +16,6 @@ class MerBeDM extends MerService
|
||||
#[ORM\Column(type: 'string', length: 255)]
|
||||
private $activation_code;
|
||||
|
||||
#[ORM\OneToOne(targetEntity: MerDM::class, cascade: ['persist'])]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private MerDM $platform;
|
||||
|
||||
// public function getId(): ?int
|
||||
// {
|
||||
// return $this->id;
|
||||
@ -36,16 +32,4 @@ class MerBeDM extends MerService
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlatform(): ?MerDM
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
public function setPlatform(?MerDM $platform): self
|
||||
{
|
||||
$this->platform = $platform;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use App\Repository\MerDMRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: MerDMRepository::class)]
|
||||
class MerDM
|
||||
class MerDM extends Platform
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
|
@ -6,7 +6,7 @@ use App\Repository\MerDTRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: MerDTRepository::class)]
|
||||
class MerDT
|
||||
class MerDT extends Platform
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
|
@ -6,7 +6,7 @@ use App\Repository\MerParaDMRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: MerParaDMRepository::class)]
|
||||
class MerParaDM extends MerService
|
||||
class MerParaDM extends MerService implements OttInterface
|
||||
{
|
||||
// #[ORM\Id]
|
||||
// #[ORM\GeneratedValue]
|
||||
@ -16,10 +16,6 @@ class MerParaDM extends MerService
|
||||
#[ORM\Column(type: 'string', length: 255)]
|
||||
private $product_code;
|
||||
|
||||
#[ORM\OneToOne(targetEntity: MerDM::class, cascade: ['persist'])]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private MerDM $platform;
|
||||
|
||||
// public function getId(): ?int
|
||||
// {
|
||||
// return $this->id;
|
||||
@ -36,16 +32,4 @@ class MerParaDM extends MerService
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlatform(): ?MerDM
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
public function setPlatform(?MerDM $platform): self
|
||||
{
|
||||
$this->platform = $platform;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use App\Repository\MerParaDTRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: MerParaDTRepository::class)]
|
||||
class MerParaDT extends MerService
|
||||
class MerParaDT extends MerService implements OttInterface
|
||||
{
|
||||
// #[ORM\Id]
|
||||
// #[ORM\GeneratedValue]
|
||||
@ -16,10 +16,6 @@ class MerParaDT extends MerService
|
||||
#[ORM\Column(type: 'string', length: 255)]
|
||||
private $api_key;
|
||||
|
||||
#[ORM\OneToOne(targetEntity: MerDT::class, cascade: ['persist'])]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private MerDT $platform;
|
||||
|
||||
// public function getId(): ?int
|
||||
// {
|
||||
// return $this->id;
|
||||
@ -36,16 +32,4 @@ class MerParaDT extends MerService
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlatform(): ?MerDT
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
public function setPlatform(?MerDT $platform): self
|
||||
{
|
||||
$this->platform = $platform;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\MerServiceRepository;
|
||||
use Doctrine\DBAL\Platforms\OraclePlatform;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\InheritanceType('SINGLE_TABLE')]
|
||||
@ -26,6 +27,9 @@ abstract class MerService
|
||||
#[ORM\Column(type: 'json', nullable: true)]
|
||||
private $metadata = [];
|
||||
|
||||
#[ORM\OneToOne(targetEntity: Platform::class, cascade: ['persist'], mappedBy: 'ott')]
|
||||
private Platform $platform;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@ -54,4 +58,16 @@ abstract class MerService
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlatform(): ?Platform
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
public function setPlatform(?Platform $platform): self
|
||||
{
|
||||
$this->platform = $platform;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
8
src/Entity/OttInterface.php
Normal file
8
src/Entity/OttInterface.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
interface OttInterface
|
||||
{
|
||||
|
||||
}
|
25
src/Entity/Platform.php
Normal file
25
src/Entity/Platform.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\MappedSuperclass]
|
||||
class Platform
|
||||
{
|
||||
#[ORM\OneToOne(targetEntity: "MerService", inversedBy: "platform")]
|
||||
#[ORM\JoinColumn(name: "ott_id", referencedColumnName: "id")]
|
||||
private ?MerService $ott;
|
||||
|
||||
public function getOtt(): ?MerService
|
||||
{
|
||||
return $this->ott;
|
||||
}
|
||||
|
||||
public function setPlatform(?MerService $ott): self
|
||||
{
|
||||
$this->ott = $ott;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user