collection-crud/src/Entity/Cpu.php

55 lines
1.3 KiB
PHP
Raw Normal View History

2022-10-13 22:26:33 -04:00
<?php declare(strict_types=1);
namespace App\Entity;
2022-11-17 15:32:57 -05:00
use App\Enum\CpuArchitecture;
use App\Repository\CpuRepository;
2023-07-21 10:35:15 -04:00
use Doctrine\Common\Collections\{ArrayCollection, Collection};
2022-10-13 22:26:33 -04:00
use Doctrine\ORM\Mapping as ORM;
2022-10-27 11:55:16 -04:00
#[ORM\Table('cpu', schema: 'collection')]
#[ORM\Entity(repositoryClass: CpuRepository::class)]
2022-10-13 22:26:33 -04:00
class Cpu {
2022-11-17 15:32:57 -05:00
use GetSet;
use CpuBase;
2022-10-13 22:26:33 -04:00
2022-10-27 11:55:16 -04:00
#[ORM\Column('id', type: 'integer', nullable: FALSE)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private int $id;
2022-10-13 22:26:33 -04:00
2022-10-20 11:07:27 -04:00
/**
* @var Collection<int, Socket>
*/
2022-11-17 15:32:57 -05:00
#[ORM\ManyToMany(targetEntity: Socket::class, inversedBy: 'cpus', fetch: 'LAZY')]
2022-10-27 11:55:16 -04:00
#[ORM\JoinTable('collection.cpu_socket_link')]
2022-10-31 21:12:48 -04:00
#[ORM\JoinColumn('cpu_id', referencedColumnName: 'id')]
#[ORM\InverseJoinColumn('socket_id', referencedColumnName: 'id')]
2022-10-20 11:07:27 -04:00
#[ORM\OrderBy(['name' => 'asc'])]
private Collection $sockets;
2022-11-17 15:32:57 -05:00
// ------------------------------------------------------------------------
2022-10-20 11:07:27 -04:00
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;
}
2022-10-13 22:26:33 -04:00
}