diff --git a/src/Controller/GpuController.php b/src/Controller/GpuController.php new file mode 100644 index 0000000..fe5d8c4 --- /dev/null +++ b/src/Controller/GpuController.php @@ -0,0 +1,56 @@ +itemListView('gpus'); + } + + #[Route('/new', name: 'gpu_new', methods: ['GET', 'POST'])] + public function new(Request $request): Response + { + return $this->itemCreate($request, 'gpu'); + } + + #[Route('/{id}', name: 'gpu_show', methods: ['GET'])] + public function show(Gpu $gpu): Response + { + return $this->itemView($gpu, 'gpu'); + } + + #[Route('/{id}/edit', name: 'gpu_edit', methods: ['GET', 'POST'])] + public function edit(Request $request, Gpu $gpu): Response + { + return $this->itemUpdate($request, $gpu, 'gpu'); + } + + #[Route('/{id}', name: 'gpu_delete', methods: ['POST'])] + public function delete(Request $request, Gpu $gpu): Response + { + return $this->deleteCSRF($request, $gpu); + } +} diff --git a/src/Controller/GpuCoreController.php b/src/Controller/GpuCoreController.php index c96d0ab..af50fa3 100644 --- a/src/Controller/GpuCoreController.php +++ b/src/Controller/GpuCoreController.php @@ -28,10 +28,12 @@ class GpuCoreController extends AbstractController public function index(): Response { return $this->indexView('gpu_cores', [ - 'brand' => 'asc', - 'architecture' => 'asc', - 'name' => 'asc', - 'variant' => 'asc', + 'brand' => 'asc', + 'processNode' => 'desc', + 'generationName' => 'asc', + 'architecture' => 'asc', + 'name' => 'asc', + 'variant' => 'asc', ]); } diff --git a/src/Entity/Gpu.php b/src/Entity/Gpu.php index 5a09ac4..5931a56 100644 --- a/src/Entity/Gpu.php +++ b/src/Entity/Gpu.php @@ -16,28 +16,109 @@ class Gpu private int $id; #[ORM\ManyToOne(targetEntity: 'Brand')] - #[ORM\JoinColumn(name: 'board_brand_id', referencedColumnName: 'id', nullable: TRUE)] - private readonly Brand $boardBrand; - - #[ORM\ManyToOne(targetEntity: 'Brand')] + #[ORM\OrderBy(['name' => 'asc'])] #[ORM\JoinColumn(name: 'gpu_brand_id', referencedColumnName: 'id', nullable: FALSE)] private readonly Brand $gpuBrand; #[ORM\ManyToOne(targetEntity: 'GpuCore')] + #[ORM\OrderBy(['brand' => 'asc', 'name' => 'asc'])] #[ORM\JoinColumn(name: 'gpu_core_id', referencedColumnName: 'id', nullable: TRUE)] private readonly GpuCore $gpuCore; #[ORM\Column(name: 'reference_model_name', nullable: FALSE)] private readonly string $modelName; + #[ORM\ManyToOne(targetEntity: 'Brand')] + #[ORM\OrderBy(['name' => 'asc'])] + #[ORM\JoinColumn(name: 'board_brand_id', referencedColumnName: 'id', nullable: TRUE)] + private ?Brand $boardBrand = NULL; + #[ORM\Column(name: 'alternate_model_name', nullable: TRUE)] - private readonly string $alternateModelName; + private ?string $alternateModelName = ''; + + #[ORM\Column(name: 'card_key', nullable: TRUE)] + private readonly ?string $cardKey; + + #[ORM\Column(name: 'bus_interface')] + private readonly ?string $busInterface; + + #[ORM\Column(name: 'slot_width')] + private int $slotWidth = 1; + + #[ORM\Column(name: 'molex_power')] + private int $molexPower = 0; + + #[ORM\Column(name: 'pcie_6_pin')] + private int $pcie6power = 0; + + #[ORM\Column(name: 'pcie_8_pin')] + private int $pcie8power = 0; + + #[ORM\Column(name: 'tdp', nullable: TRUE)] + private readonly ?int $tdp; + + #[ORM\Column(name: 'base_clock')] + private readonly ?int $baseClock; + + #[ORM\Column(name: 'boost_clock')] + private readonly ?int $boostClock; + + #[ORM\Column(name: 'memory_clock')] + private readonly ?int $memoryClock; + + #[ORM\Column(name: 'memory_size')] + private readonly ?int $memorySize; + + #[ORM\Column(name: 'memory_bus')] + private readonly ?int $memoryBus; + + #[ORM\Column(name: 'memory_type')] + private readonly ?string $memoryType; + + #[ORM\Column(name: 'shading_units')] + private readonly ?int $shadingUnits; + + #[ORM\Column(name: 'tmus')] + private readonly ?int $tmus; + + #[ORM\Column(name: 'rops')] + private readonly ?int $rops; + + #[ORM\Column(name: 'compute_units')] + private readonly ?int $computeUnits; + + #[ORM\Column(name: 'l1_cache')] + private readonly ?string $l1cache; + + #[ORM\Column(name: 'l2_cache')] + private readonly ?string $l2cache; + + #[ORM\Column(name: 'direct_x_support')] + private readonly ?string $directXSupport; + + #[ORM\Column(name: 'opengl_support')] + private readonly ?string $openGLSupport; + + #[ORM\Column(name: 'opencl_support')] + private readonly ?string $openCLSupport; + + #[ORM\Column(name: 'vulkan_support')] + private readonly ?string $vulkanSupport; + + #[ORM\Column(name: 'shader_model')] + private readonly ?string $shaderModel; + + #[ORM\Column(name: 'link')] + private readonly string $link; #[ORM\Column(name: 'count', nullable: FALSE)] - private readonly int $count; + private int $count = 1; + + #[ORM\Column(name: 'acquired')] + private bool $acquired; #[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)] - private readonly string $notes; + private ?string $notes = ''; public function getId(): ?int { @@ -68,6 +149,306 @@ class Gpu return $this; } + public function getCardKey(): ?string + { + return $this->cardKey; + } + + public function setCardKey(?string $cardKey): self + { + $this->cardKey = $cardKey; + + return $this; + } + + public function getBusInterface(): ?string + { + return $this->busInterface; + } + + public function setBusInterface(string $busInterface): self + { + $this->busInterface = $busInterface; + + return $this; + } + + public function getSlotWidth(): ?int + { + return $this->slotWidth; + } + + public function setSlotWidth(int $slotWidth): self + { + $this->slotWidth = $slotWidth; + + return $this; + } + + public function getMolexPower(): ?int + { + return $this->molexPower; + } + + public function setMolexPower(int $molexPower): self + { + $this->molexPower = $molexPower; + + return $this; + } + + public function getPcie6power(): ?int + { + return $this->pcie6power; + } + + public function setPcie6power(int $pcie6power): self + { + $this->pcie6power = $pcie6power; + + return $this; + } + + public function getPcie8power(): ?int + { + return $this->pcie8power; + } + + public function setPcie8power(int $pcie8power): self + { + $this->pcie8power = $pcie8power; + + return $this; + } + + public function getTdp(): ?int + { + return $this->tdp; + } + + public function setTdp(?int $tdp): self + { + $this->tdp = $tdp; + + return $this; + } + + public function getBaseClock(): ?int + { + return $this->baseClock; + } + + public function setBaseClock(int $baseClock): self + { + $this->baseClock = $baseClock; + + return $this; + } + + public function getBoostClock(): ?int + { + return $this->boostClock; + } + + public function setBoostClock(int $boostClock): self + { + $this->boostClock = $boostClock; + + return $this; + } + + public function getMemoryClock(): ?int + { + return $this->memoryClock; + } + + public function setMemoryClock(int $memoryClock): self + { + $this->memoryClock = $memoryClock; + + return $this; + } + + public function getMemorySize(): ?int + { + return $this->memorySize; + } + + public function setMemorySize(int $memorySize): self + { + $this->memorySize = $memorySize; + + return $this; + } + + public function getMemoryBus(): ?int + { + return $this->memoryBus; + } + + public function setMemoryBus(int $memoryBus): self + { + $this->memoryBus = $memoryBus; + + return $this; + } + + public function getMemoryType(): ?string + { + return $this->memoryType; + } + + public function setMemoryType(string $memoryType): self + { + $this->memoryType = $memoryType; + + return $this; + } + + public function getShadingUnits(): ?int + { + return $this->shadingUnits; + } + + public function setShadingUnits(int $shadingUnits): self + { + $this->shadingUnits = $shadingUnits; + + return $this; + } + + public function getTmus(): ?int + { + return $this->tmus; + } + + public function setTmus(int $tmus): self + { + $this->tmus = $tmus; + + return $this; + } + + public function getRops(): ?int + { + return $this->rops; + } + + public function setRops(int $rops): self + { + $this->rops = $rops; + + return $this; + } + + public function getComputeUnits(): ?int + { + return $this->computeUnits; + } + + public function setComputeUnits(int $computeUnits): self + { + $this->computeUnits = $computeUnits; + + return $this; + } + + public function getL1cache(): ?string + { + return $this->l1cache; + } + + public function setL1cache(string $l1cache): self + { + $this->l1cache = $l1cache; + + return $this; + } + + public function getL2cache(): ?string + { + return $this->l2cache; + } + + public function setL2cache(string $l2cache): self + { + $this->l2cache = $l2cache; + + return $this; + } + + public function getDirectXSupport(): ?string + { + return $this->directXSupport; + } + + public function setDirectXSupport(string $directXSupport): self + { + $this->directXSupport = $directXSupport; + + return $this; + } + + public function getOpenGLSupport(): ?string + { + return $this->openGLSupport; + } + + public function setOpenGLSupport(string $openGLSupport): self + { + $this->openGLSupport = $openGLSupport; + + return $this; + } + + public function getOpenCLSupport(): ?string + { + return $this->openCLSupport; + } + + public function setOpenCLSupport(string $openCLSupport): self + { + $this->openCLSupport = $openCLSupport; + + return $this; + } + + public function getVulkanSupport(): ?string + { + return $this->vulkanSupport; + } + + public function setVulkanSupport(string $vulkanSupport): self + { + $this->vulkanSupport = $vulkanSupport; + + return $this; + } + + public function getShaderModel(): ?string + { + return $this->shaderModel; + } + + public function setShaderModel(string $shaderModel): self + { + $this->shaderModel = $shaderModel; + + return $this; + } + + public function getLink(): ?string + { + return $this->link; + } + + public function setLink(string $link): self + { + $this->link = $link; + + return $this; + } + public function getCount(): ?int { return $this->count; @@ -80,6 +461,18 @@ class Gpu return $this; } + public function isAcquired(): ?bool + { + return $this->acquired; + } + + public function setAcquired(bool $acquired): self + { + $this->acquired = $acquired; + + return $this; + } + public function getNotes(): ?string { return $this->notes; @@ -92,18 +485,6 @@ class Gpu return $this; } - public function getBoardBrand(): ?Brand - { - return $this->boardBrand; - } - - public function setBoardBrand(?Brand $boardBrand): self - { - $this->boardBrand = $boardBrand; - - return $this; - } - public function getGpuBrand(): ?Brand { return $this->gpuBrand; @@ -127,4 +508,16 @@ class Gpu return $this; } + + public function getBoardBrand(): ?Brand + { + return $this->boardBrand; + } + + public function setBoardBrand(?Brand $boardBrand): self + { + $this->boardBrand = $boardBrand; + + return $this; + } } diff --git a/src/Entity/GpuCore.php b/src/Entity/GpuCore.php index fc37192..3e75b92 100644 --- a/src/Entity/GpuCore.php +++ b/src/Entity/GpuCore.php @@ -3,10 +3,11 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; +use Stringable; #[ORM\Table(name: 'gpu_core', schema: 'collection')] #[ORM\Entity] -class GpuCore +class GpuCore implements Stringable { use GetSetTrait; @@ -16,6 +17,7 @@ class GpuCore private int $id; #[ORM\ManyToOne(targetEntity: 'Brand')] + #[ORM\OrderBy(['name' => 'asc'])] #[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id')] private Brand $brand; @@ -28,6 +30,9 @@ class GpuCore #[ORM\Column(name: 'generation_name')] private readonly string $generationName; + #[ORM\Column(name: 'generation_link', nullable: TRUE)] + private ?string $generationLink = ''; + #[ORM\Column(name: 'architecture')] private readonly string $architecture; @@ -83,6 +88,18 @@ class GpuCore return $this; } + public function getGenerationLink(): ?string + { + return $this->generationLink; + } + + public function setGenerationLink(?string $generationLink): self + { + $this->generationLink = $generationLink; + + return $this; + } + public function getArchitecture(): ?string { return $this->architecture; diff --git a/src/Form/GPUCoreType.php b/src/Form/GPUCoreType.php index 8d38d0d..e596e76 100644 --- a/src/Form/GPUCoreType.php +++ b/src/Form/GPUCoreType.php @@ -2,7 +2,9 @@ namespace App\Form; -use App\Entity\GpuCore; +use App\Entity\{Brand, GpuCore}; +use Doctrine\ORM\EntityRepository; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\{AbstractType, FormBuilderInterface}; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -11,12 +13,16 @@ class GPUCoreType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { $builder - ->add('brand') + ->add('brand', EntityType::class, [ + 'class' => Brand::class, + 'query_builder' => static fn (EntityRepository $e) => $e->createQueryBuilder('b')->orderBy('b.name', 'ASC'), + ]) ->add('name') ->add('variant') ->add('architecture') ->add('architectureLink') ->add('generationName') + ->add('generationLink') ->add('processNode'); } diff --git a/src/Form/GpuType.php b/src/Form/GpuType.php new file mode 100644 index 0000000..ac8c00c --- /dev/null +++ b/src/Form/GpuType.php @@ -0,0 +1,69 @@ + $e->createQueryBuilder('b')->orderBy('b.name', 'ASC'); + + $builder + ->add('gpuBrand', EntityType::class, [ + 'class' => Brand::class, + 'query_builder' => $brandQueryBuilder, + ]) + ->add('modelName') + ->add('gpuCore', EntityType::class, [ + 'class' => GpuCore::class, + 'query_builder' => static fn (EntityRepository $e) => $e->createQueryBuilder('gc')->orderBy('gc.brand', 'ASC')->orderBy('gc.name', 'ASC'), + ]) + ->add('boardBrand', EntityType::class, [ + 'class' => Brand::class, + 'query_builder' => $brandQueryBuilder, + 'empty_data' => NULL, + ]) + ->add('alternateModelName') + ->add('cardKey') + ->add('busInterface') + ->add('slotWidth') + ->add('molexPower') + ->add('pcie6power') + ->add('pcie8power') + ->add('tdp') + ->add('baseClock') + ->add('boostClock') + ->add('memoryClock') + ->add('memorySize') + ->add('memoryBus') + ->add('memoryType') + ->add('shadingUnits') + ->add('tmus') + ->add('rops') + ->add('computeUnits') + ->add('l1cache') + ->add('l2cache') + ->add('directXSupport') + ->add('openGLSupport') + ->add('openCLSupport') + ->add('vulkanSupport') + ->add('shaderModel') + ->add('link') + ->add('count') + ->add('acquired') + ->add('notes'); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Gpu::class, + ]); + } +} diff --git a/templates/gpu_core/index.html.twig b/templates/gpu_core/index.html.twig index af8842d..7190069 100644 --- a/templates/gpu_core/index.html.twig +++ b/templates/gpu_core/index.html.twig @@ -21,7 +21,7 @@ Brand Name Variant - GenerationName + Generation Architecture ProcessNode @@ -43,9 +43,24 @@ {{ gpu_core.brand.name }} {{ gpu_core.name }} {{ gpu_core.variant }} - {{ gpu_core.generationName }} - {{ gpu_core.architecture }} - {{ gpu_core.processNode }}nm + + {% if gpu_core.generationLink %} + {{ gpu_core.generationName }} + {% else %} + {{ gpu_core.generationName }} + {% endif %} + + {% if gpu_core.architectureLink %} + {{ gpu_core.architecture }} + {% else %} + {{ gpu_core.architecture }} + {% endif %} + + {% if gpu_core.processNode %} + {{ gpu_core.processNode }} nm + {% else %} + ? + {% endif %} {% else %} diff --git a/templates/gpu_core/show.html.twig b/templates/gpu_core/show.html.twig index 8a7fcd8..7b93895 100644 --- a/templates/gpu_core/show.html.twig +++ b/templates/gpu_core/show.html.twig @@ -42,15 +42,27 @@ GenerationName - {{ gpu_core.generationName }} + {% if gpu_core.generationLink %} + {{ gpu_core.generationName }} + {% else %} + {{ gpu_core.generationName }} + {% endif %} Architecture - {{ gpu_core.architecture }} + {% if gpu_core.architectureLink %} + {{ gpu_core.architecture }} + {% else %} + {{ gpu_core.architecture }} + {% endif %} ProcessNode - {{ gpu_core.processNode }}nm + {% if gpu_core.processNode %} + {{ gpu_core.processNode }} nm + {% else %} + ? + {% endif %}