55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\Common\Collections\{Collection, ArrayCollection};
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Table(name: 'cpu', schema: 'collection')]
|
|
#[ORM\Entity]
|
|
class Cpu {
|
|
use GetSetTrait;
|
|
|
|
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
|
|
private int $id;
|
|
|
|
#[ORM\ManyToOne(targetEntity: 'Brand')]
|
|
#[ORM\OrderBy(['name' => 'asc'])]
|
|
#[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id', nullable: FALSE)]
|
|
private Brand $brand;
|
|
|
|
/**
|
|
* @var Collection<int, Socket>
|
|
*/
|
|
#[ORM\ManyToMany(targetEntity: Socket::class)]
|
|
#[ORM\JoinTable(name: 'collection.cpu_socket_link')]
|
|
#[ORM\JoinColumn(name: 'socket_id', referencedColumnName: 'id')]
|
|
#[ORM\InverseJoinColumn(name: 'cpu_id', referencedColumnName: 'id')]
|
|
#[ORM\OrderBy(['name' => 'asc'])]
|
|
private Collection $sockets;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->sockets = new ArrayCollection();
|
|
}
|
|
|
|
public function addSocket(Socket $socket): self
|
|
{
|
|
if ( ! $this->sockets->contains($socket))
|
|
{
|
|
$this->sockets->add($socket);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeSocket(Socket $socket): self
|
|
{
|
|
$this->sockets->removeElement($socket);
|
|
|
|
return $this;
|
|
}
|
|
}
|