diff --git a/src/Controller/GpuController.php b/src/Controller/GpuController.php index fe5d8c4..546b96e 100644 --- a/src/Controller/GpuController.php +++ b/src/Controller/GpuController.php @@ -27,7 +27,17 @@ class GpuController extends AbstractController #[Route('/', name: 'gpu_index', methods: ['GET'])] public function index(): Response { - return $this->itemListView('gpus'); + $acquiredItems = $this->entityManager->getRepository(self::ENTITY)->findBy([ + 'acquired' => TRUE, + ], []); + $newItems = $this->entityManager->getRepository(self::ENTITY)->findBy([ + 'acquired' => FALSE, + ], []); + + return $this->render('gpu/index.html.twig', [ + 'not_acquired' => $newItems, + 'acquired' => $acquiredItems, + ]); } #[Route('/new', name: 'gpu_new', methods: ['GET', 'POST'])] diff --git a/src/Entity/Brand.php b/src/Entity/Brand.php index 7d6b555..b32ab15 100644 --- a/src/Entity/Brand.php +++ b/src/Entity/Brand.php @@ -2,6 +2,8 @@ namespace App\Entity; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; #[ORM\Table(name: 'brand', schema: 'collection')] @@ -16,9 +18,21 @@ class Brand #[ORM\SequenceGenerator(sequenceName: 'brand_id_seq', allocationSize: 1, initialValue: 1)] private int $id; + #[ORM\ManyToMany(targetEntity: BrandCategory::class)] + #[ORM\JoinTable(name: 'collection.brand_category_link')] + #[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id')] + #[ORM\InverseJoinColumn(name: 'brand_category', referencedColumnName: 'category_name')] + #[ORM\OrderBy(['name' => 'asc'])] + private $categories; + #[ORM\Column(name: 'name', unique: TRUE, nullable: FALSE)] private string $name; + public function __construct() + { + $this->categories = new ArrayCollection(); + } + public function __toString(): string { return $this->name; @@ -40,4 +54,28 @@ class Brand return $this; } + + /** + * @return Collection + */ + public function getCategories(): Collection + { + return $this->categories; + } + + public function addCategory(BrandCategory $category): self + { + if (!$this->categories->contains($category)) { + $this->categories->add($category); + } + + return $this; + } + + public function removeCategory(BrandCategory $category): self + { + $this->categories->removeElement($category); + + return $this; + } } diff --git a/src/Entity/BrandCategory.php b/src/Entity/BrandCategory.php new file mode 100644 index 0000000..afbc4ba --- /dev/null +++ b/src/Entity/BrandCategory.php @@ -0,0 +1,31 @@ + 'asc'])] + private string $name; + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } + + public function __toString(): string + { + return $this->name; + } +} diff --git a/src/Entity/CameraType.php b/src/Entity/CameraType.php index 91763fd..71d73dc 100644 --- a/src/Entity/CameraType.php +++ b/src/Entity/CameraType.php @@ -2,6 +2,7 @@ namespace App\Entity; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Stringable; diff --git a/src/Entity/Film.php b/src/Entity/Film.php index 4a80482..c3bb132 100644 --- a/src/Entity/Film.php +++ b/src/Entity/Film.php @@ -2,6 +2,7 @@ namespace App\Entity; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; /** diff --git a/src/Entity/Gpu.php b/src/Entity/Gpu.php index 5931a56..3fa7f26 100644 --- a/src/Entity/Gpu.php +++ b/src/Entity/Gpu.php @@ -2,6 +2,7 @@ namespace App\Entity; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; #[ORM\Table(name: 'gpu', schema: 'collection')] @@ -18,15 +19,15 @@ class Gpu #[ORM\ManyToOne(targetEntity: 'Brand')] #[ORM\OrderBy(['name' => 'asc'])] #[ORM\JoinColumn(name: 'gpu_brand_id', referencedColumnName: 'id', nullable: FALSE)] - private readonly Brand $gpuBrand; + private 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; + private GpuCore $gpuCore; #[ORM\Column(name: 'reference_model_name', nullable: FALSE)] - private readonly string $modelName; + private string $modelName; #[ORM\ManyToOne(targetEntity: 'Brand')] #[ORM\OrderBy(['name' => 'asc'])] @@ -37,10 +38,10 @@ class Gpu private ?string $alternateModelName = ''; #[ORM\Column(name: 'card_key', nullable: TRUE)] - private readonly ?string $cardKey; + private ?string $cardKey; - #[ORM\Column(name: 'bus_interface')] - private readonly ?string $busInterface; + #[ORM\Column(name: 'bus_interface', nullable: TRUE)] + private ?string $busInterface; #[ORM\Column(name: 'slot_width')] private int $slotWidth = 1; @@ -57,56 +58,56 @@ class Gpu #[ORM\Column(name: 'tdp', nullable: TRUE)] private readonly ?int $tdp; - #[ORM\Column(name: 'base_clock')] - private readonly ?int $baseClock; + #[ORM\Column(name: 'base_clock', nullable: TRUE)] + private ?int $baseClock; - #[ORM\Column(name: 'boost_clock')] - private readonly ?int $boostClock; + #[ORM\Column(name: 'boost_clock', nullable: TRUE)] + private ?int $boostClock; - #[ORM\Column(name: 'memory_clock')] - private readonly ?int $memoryClock; + #[ORM\Column(name: 'memory_clock', nullable: TRUE)] + private ?int $memoryClock; - #[ORM\Column(name: 'memory_size')] - private readonly ?int $memorySize; + #[ORM\Column(name: 'memory_size', nullable: TRUE)] + private ?int $memorySize; - #[ORM\Column(name: 'memory_bus')] - private readonly ?int $memoryBus; + #[ORM\Column(name: 'memory_bus', nullable: TRUE)] + private ?int $memoryBus; - #[ORM\Column(name: 'memory_type')] - private readonly ?string $memoryType; + #[ORM\Column(name: 'memory_type', nullable: TRUE)] + private ?string $memoryType; - #[ORM\Column(name: 'shading_units')] - private readonly ?int $shadingUnits; + #[ORM\Column(name: 'shading_units', nullable: TRUE)] + private ?int $shadingUnits; - #[ORM\Column(name: 'tmus')] - private readonly ?int $tmus; + #[ORM\Column(name: 'tmus', nullable: TRUE)] + private ?int $tmus; - #[ORM\Column(name: 'rops')] - private readonly ?int $rops; + #[ORM\Column(name: 'rops', nullable: TRUE)] + private ?int $rops; - #[ORM\Column(name: 'compute_units')] - private readonly ?int $computeUnits; + #[ORM\Column(name: 'compute_units', nullable: TRUE)] + private ?int $computeUnits; - #[ORM\Column(name: 'l1_cache')] - private readonly ?string $l1cache; + #[ORM\Column(name: 'l1_cache', nullable: TRUE)] + private ?string $l1cache; - #[ORM\Column(name: 'l2_cache')] - private readonly ?string $l2cache; + #[ORM\Column(name: 'l2_cache', nullable: TRUE)] + private ?string $l2cache; - #[ORM\Column(name: 'direct_x_support')] - private readonly ?string $directXSupport; + #[ORM\Column(name: 'direct_x_support', nullable: TRUE)] + private ?string $directXSupport; - #[ORM\Column(name: 'opengl_support')] - private readonly ?string $openGLSupport; + #[ORM\Column(name: 'opengl_support', nullable: TRUE)] + private ?string $openGLSupport; - #[ORM\Column(name: 'opencl_support')] - private readonly ?string $openCLSupport; + #[ORM\Column(name: 'opencl_support', nullable: TRUE)] + private ?string $openCLSupport; - #[ORM\Column(name: 'vulkan_support')] - private readonly ?string $vulkanSupport; + #[ORM\Column(name: 'vulkan_support', nullable: TRUE)] + private ?string $vulkanSupport; - #[ORM\Column(name: 'shader_model')] - private readonly ?string $shaderModel; + #[ORM\Column(name: 'shader_model', nullable: TRUE)] + private ?string $shaderModel; #[ORM\Column(name: 'link')] private readonly string $link; diff --git a/src/Entity/GpuCore.php b/src/Entity/GpuCore.php index 3e75b92..5014463 100644 --- a/src/Entity/GpuCore.php +++ b/src/Entity/GpuCore.php @@ -44,7 +44,11 @@ class GpuCore implements Stringable public function __toString(): string { - return "{$this->brand} {$this->name} ({$this->variant}/{$this->generationName})"; + $name = ( ! empty($this->variant)) + ? "{$this->name} ({$this->variant})" + : $this->name; + + return "{$name} - [{$this->brand}] $this->generationName"; } public function getId(): ?int diff --git a/src/Form/BrandType.php b/src/Form/BrandType.php index f354079..b484ef5 100644 --- a/src/Form/BrandType.php +++ b/src/Form/BrandType.php @@ -4,6 +4,9 @@ namespace App\Form; use App\Entity\Brand; use Symfony\Component\Form\{AbstractType, FormBuilderInterface}; +use App\Entity\BrandCategory; +use Doctrine\ORM\EntityRepository; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\OptionsResolver\OptionsResolver; class BrandType extends AbstractType @@ -11,7 +14,8 @@ class BrandType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { $builder - ->add('name'); + ->add('name') + ->add('categories'); } public function configureOptions(OptionsResolver $resolver): void diff --git a/src/Form/GpuType.php b/src/Form/GpuType.php index ac8c00c..d458a6d 100644 --- a/src/Form/GpuType.php +++ b/src/Form/GpuType.php @@ -28,30 +28,32 @@ class GpuType extends AbstractType 'class' => Brand::class, 'query_builder' => $brandQueryBuilder, 'empty_data' => NULL, + 'placeholder' => 'Unknown', + 'required' => false, ]) ->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('molexPower', null, ['label' => 'Molex Power Connectors']) + ->add('pcie6power', null, ['label' => 'PCIe 6-pin Power Connectors']) + ->add('pcie8power', null, ['label' => 'PCIe 8-pin Power Connectors']) + ->add('tdp', null, ['label' => 'TDP (Watts)']) + ->add('baseClock', null, ['label' => 'GPU Base Clock (MHz)']) + ->add('boostClock', null, ['label' => 'GPU Boost Clock (MHz)']) + ->add('memoryClock', null, ['label' => 'Memory Speed (MHz)']) + ->add('memorySize', null, ['label' => 'Memory Size (MB)']) + ->add('memoryBus', null, ['label' => 'Memory Bus Size (bits)']) ->add('memoryType') ->add('shadingUnits') - ->add('tmus') - ->add('rops') + ->add('tmus', null, ['label' => 'TMUs']) + ->add('rops', null, ['label' => 'ROPs']) ->add('computeUnits') - ->add('l1cache') - ->add('l2cache') - ->add('directXSupport') - ->add('openGLSupport') - ->add('openCLSupport') + ->add('l1cache', null, ['label' => 'L1 Cache']) + ->add('l2cache', null, ['label' => 'L2 Cache']) + ->add('directXSupport', null, ['label' => 'DirectX Support']) + ->add('openGLSupport', null, ['label' => 'OpenGL Support']) + ->add('openCLSupport', null, ['label' => 'OpenCL Support']) ->add('vulkanSupport') ->add('shaderModel') ->add('link') diff --git a/src/Repository/BrandRepository.php b/src/Repository/BrandRepository.php new file mode 100644 index 0000000..a51484c --- /dev/null +++ b/src/Repository/BrandRepository.php @@ -0,0 +1,28 @@ +getEntityManager(); + $query = $em->createQuery(" + SELECT b FROM App\Entity\Brand b + INNER JOIN b.categories c WHERE c.name = ?1 + ORDER BY b.name ASC + "); + $query->setParameter(1, $category); + + return $query->execute(); + } +} diff --git a/templates/brand/index.html.twig b/templates/brand/index.html.twig index 88a0a1a..1f67c8f 100644 --- a/templates/brand/index.html.twig +++ b/templates/brand/index.html.twig @@ -16,9 +16,10 @@ - + + @@ -36,6 +37,13 @@ + {% else %} diff --git a/templates/brand/show.html.twig b/templates/brand/show.html.twig index eb65b97..8bcb091 100644 --- a/templates/brand/show.html.twig +++ b/templates/brand/show.html.twig @@ -3,7 +3,7 @@ {% block title %}Brand{% endblock %} {% block form %} -

Brand

+

Brand

-
+
-
+
-
Actions  Id NameCategories
{{ brand.id }} {{ brand.name }} +
    + {% for category in brand.categories %} +
  • {{ category }}
  • + {% endfor %} +
+
- - - - - - - - - - -
Id{{ brand.id }}
Name{{ brand.name }}
+ + + + + + + + + + + + + + + +
Id{{ brand.id }}
Name{{ brand.name }}
Categories +
    + {% for category in brand.categories %} +
  • {{ category }}
  • + {% endfor %} +
+
{% endblock %} diff --git a/templates/gpu/_delete_form.html.twig b/templates/gpu/_delete_form.html.twig deleted file mode 100644 index 229326d..0000000 --- a/templates/gpu/_delete_form.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -
- - -
diff --git a/templates/gpu/_form.html.twig b/templates/gpu/_form.html.twig deleted file mode 100644 index 6e72c1c..0000000 --- a/templates/gpu/_form.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -{{ form_start(form) }} - {{ form_widget(form) }} - -{{ form_end(form) }} diff --git a/templates/gpu/edit.html.twig b/templates/gpu/edit.html.twig index 9490f05..3fef0c2 100644 --- a/templates/gpu/edit.html.twig +++ b/templates/gpu/edit.html.twig @@ -3,7 +3,7 @@ {% block title %}Edit Gpu{% endblock %} {% block form %} -

Edit Graphics Card

+

Edit Graphics Card

-
+
{{ form_start(edit_form) }} +
+ Names / Brands + + {{ form_row(edit_form.gpuBrand) }} + {{ form_row(edit_form.modelName) }} + {{ form_row(edit_form.gpuCore) }} + +
+ + {{ form_row(edit_form.boardBrand) }} + {{ form_row(edit_form.alternateModelName) }} +
+ +
+ Bus / Size + + {{ form_row(edit_form.cardKey) }} + {{ form_row(edit_form.busInterface) }} + {{ form_row(edit_form.slotWidth) }} +
+ +
+ Power + + {{ form_row(edit_form.molexPower) }} + {{ form_row(edit_form.pcie6power) }} + {{ form_row(edit_form.pcie8power) }} + {{ form_row(edit_form.tdp) }} +
+ +
+ Clock Speeds + + {{ form_row(edit_form.baseClock) }} + {{ form_row(edit_form.boostClock) }} + {{ form_row(edit_form.memoryClock) }} +
+ +
+ Memory + + {{ form_row(edit_form.memorySize) }} + {{ form_row(edit_form.memoryBus) }} + {{ form_row(edit_form.memoryType) }} +
+ +
+ Rendering Hardware + + {{ form_row(edit_form.shadingUnits) }} + {{ form_row(edit_form.tmus) }} + {{ form_row(edit_form.rops) }} + {{ form_row(edit_form.computeUnits) }} + {{ form_row(edit_form.l1cache) }} + {{ form_row(edit_form.l2cache) }} +
+ +
+ API Support + + {{ form_row(edit_form.directXSupport) }} + {{ form_row(edit_form.openGLSupport) }} + {{ form_row(edit_form.openCLSupport) }} + {{ form_row(edit_form.vulkanSupport) }} + {{ form_row(edit_form.shaderModel) }} +
+ +
+ Misc. + + {{ form_row(edit_form.link) }} + {{ form_row(edit_form.count) }} + {{ form_row(edit_form.acquired) }} + {{ form_row(edit_form.notes) }} +
{{ form_widget(edit_form) }} - {{ form_end(form) }} -
+ {{ form_start(form) }} +
+ Names / Brands + + {{ form_row(form.gpuBrand) }} + {{ form_row(form.modelName) }} + {{ form_row(form.gpuCore) }} + +
+ + {{ form_row(form.boardBrand) }} + {{ form_row(form.alternateModelName) }} +
+ +
+ Bus / Size + + {{ form_row(form.cardKey) }} + {{ form_row(form.busInterface) }} + {{ form_row(form.slotWidth) }} +
+ +
+ Power + + {{ form_row(form.molexPower) }} + {{ form_row(form.pcie6power) }} + {{ form_row(form.pcie8power) }} + {{ form_row(form.tdp) }} +
+ +
+ Clock Speeds + + {{ form_row(form.baseClock) }} + {{ form_row(form.boostClock) }} + {{ form_row(form.memoryClock) }} +
+ +
+ Memory + + {{ form_row(form.memorySize) }} + {{ form_row(form.memoryBus) }} + {{ form_row(form.memoryType) }} +
+ +
+ Rendering Hardware + + {{ form_row(form.shadingUnits) }} + {{ form_row(form.tmus) }} + {{ form_row(form.rops) }} + {{ form_row(form.computeUnits) }} + {{ form_row(form.l1cache) }} + {{ form_row(form.l2cache) }} +
+ +
+ API Support + + {{ form_row(form.directXSupport) }} + {{ form_row(form.openGLSupport) }} + {{ form_row(form.openCLSupport) }} + {{ form_row(form.vulkanSupport) }} + {{ form_row(form.shaderModel) }} +
+ +
+ Misc. + + {{ form_row(form.link) }} + {{ form_row(form.count) }} + {{ form_row(form.acquired) }} + {{ form_row(form.notes) }} +
+ {{ form_widget(form) }} + + {{ form_end(form) }} {% endblock %} diff --git a/templates/gpu/show.html.twig b/templates/gpu/show.html.twig index a8a702c..0a824f0 100644 --- a/templates/gpu/show.html.twig +++ b/templates/gpu/show.html.twig @@ -3,7 +3,7 @@ {% block title %}Gpu{% endblock %} {% block form %} -

Graphics Card

+

Graphics Card

    @@ -15,8 +15,10 @@
+
+
@@ -24,53 +26,134 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Id{{ gpu.id }}
ModelName{{ gpu.modelName }}
AlternateModelName{{ gpu.alternateModelName }}
MolexPower{{ gpu.molexPower }}
Pcie6power{{ gpu.pcie6power }}
Pcie8power{{ gpu.pcie8power }}
CardKey{{ gpu.cardKey }}
Tdp{{ gpu.tdp }}
Link{{ gpu.link }}
Count{{ gpu.count }}
Notes{{ gpu.notes }}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id{{ gpu.id }}
ModelName{{ gpu.modelName }}
AlternateModelName{{ gpu.alternateModelName }}
CardKey{{ gpu.cardKey }}
BusInterface{{ gpu.busInterface }}
SlotWidth{{ gpu.slotWidth }}
MolexPower{{ gpu.molexPower }}
Pcie6power{{ gpu.pcie6power }}
Pcie8power{{ gpu.pcie8power }}
Tdp{{ gpu.tdp }}
BaseClock{{ gpu.baseClock }}
BoostClock{{ gpu.boostClock }}
MemoryClock{{ gpu.memoryClock }}
MemorySize{{ gpu.memorySize }}
MemoryBus{{ gpu.memoryBus }}
MemoryType{{ gpu.memoryType }}
ShadingUnits{{ gpu.shadingUnits }}
Tmus{{ gpu.tmus }}
Rops{{ gpu.rops }}
ComputeUnits{{ gpu.computeUnits }}
L1cache{{ gpu.l1cache }}
L2cache{{ gpu.l2cache }}
DirectXSupport{{ gpu.directXSupport }}
OpenGLSupport{{ gpu.openGLSupport }}
OpenCLSupport{{ gpu.openCLSupport }}
VulkanSupport{{ gpu.vulkanSupport }}
ShaderModel{{ gpu.shaderModel }}
Link{{ gpu.link }}
Count{{ gpu.count }}
Acquired{{ gpu.acquired ? 'Yes' : 'No' }}
Notes{{ gpu.notes }}
+ {% endblock %}