71 lines
1.7 KiB
PHP
71 lines
1.7 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\Common\Collections\{ArrayCollection, Collection};
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Table(name: 'motherboard', schema: 'collection')]
|
|
#[ORM\Entity]
|
|
class Motherboard {
|
|
use GetSet;
|
|
|
|
#[ORM\Column('id', type: 'integer', nullable: FALSE)]
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
|
|
private int $id;
|
|
|
|
#[ORM\ManyToOne(targetEntity: Brand::class, fetch: 'EAGER')]
|
|
#[ORM\OrderBy(['name' => 'asc'])]
|
|
#[ORM\JoinColumn('brand_id', referencedColumnName: 'id', nullable: FALSE)]
|
|
private Brand $brand;
|
|
|
|
#[ORM\Column('model', type: 'string')]
|
|
private string $model;
|
|
|
|
/**
|
|
* @var Collection<int, Socket>
|
|
*/
|
|
#[ORM\ManyToMany(targetEntity: Socket::class, inversedBy: 'cpus', fetch: 'LAZY')]
|
|
#[ORM\JoinTable('collection.motherboard_socket_link')]
|
|
#[ORM\JoinColumn('motherboard_id', referencedColumnName: 'id')]
|
|
#[ORM\InverseJoinColumn('socket_id', referencedColumnName: 'id')]
|
|
#[ORM\OrderBy(['name' => 'asc'])]
|
|
private Collection $sockets;
|
|
|
|
#[ORM\ManyToOne(targetEntity: Chipset::class, fetch: 'EAGER')]
|
|
#[ORM\OrderBy(['name' => 'asc'])]
|
|
#[ORM\JoinColumn('chipset_id', 'id', FALSE)]
|
|
private Chipset $chipset;
|
|
|
|
#[ORM\Column('link', type: 'string')]
|
|
private string $link;
|
|
|
|
#[ORM\Column('notes', type: 'text', nullable: TRUE)]
|
|
private ?string $notes = '';
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
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;
|
|
}
|
|
}
|