40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\Common\Collections\{ArrayCollection, Collection};
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Stringable;
|
|
|
|
#[ORM\Table(name: 'chipset', schema: 'collection')]
|
|
#[ORM\Entity]
|
|
class Chipset implements Stringable {
|
|
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('name', type: 'string', nullable: FALSE)]
|
|
private string $name;
|
|
|
|
#[ORM\Column('parts', type: 'string', nullable: FALSE)]
|
|
private string $parts;
|
|
|
|
#[ORM\Column('link', type: 'string', nullable: TRUE)]
|
|
private ?string $link;
|
|
|
|
public function __toString(): string
|
|
{
|
|
$name = $this->brand->getName() . ' ' . $this->name;
|
|
|
|
return (string) (($this->parts !== '') ? "{$name} ({$this->parts})" : $name);
|
|
}
|
|
}
|