Add Start of computer collection

This commit is contained in:
Timothy Warren 2022-09-29 20:09:31 -04:00
parent 21f750e97a
commit 5065bef545
34 changed files with 1059 additions and 451 deletions

View File

@ -0,0 +1,99 @@
<?php
namespace App\Controller;
use App\Entity\Brand;
use App\Form\BrandType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[Route('/brand')]
class BrandController extends AbstractController
{
use FormControllerTrait;
protected const ENTITY = Brand::class;
protected const TEMPLATE_PATH = 'brand/';
protected const ROUTE_PREFIX = 'brand_';
protected const FORM = BrandType::class;
public function __construct(private readonly EntityManagerInterface $entityManager)
{
}
#[Route('/', name: 'brand_index', methods: ['GET'])]
public function index(EntityManagerInterface $entityManager): Response
{
$brands = $entityManager
->getRepository(Brand::class)
->findBy([
], [
'name' => 'asc'
]);
return $this->render('brand/index.html.twig', [
'brands' => $brands,
]);
}
#[Route('/new', name: 'brand_new', methods: ['GET', 'POST'])]
public function new(Request $request, EntityManagerInterface $entityManager): Response
{
$brand = new Brand();
$form = $this->createForm(BrandType::class, $brand);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->persist($brand);
$entityManager->flush();
return $this->redirectToRoute('brand_index', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('brand/new.html.twig', [
'brand' => $brand,
'form' => $form,
]);
}
#[Route('/{id}', name: 'brand_show', methods: ['GET'])]
public function show(Brand $brand): Response
{
return $this->render('brand/show.html.twig', [
'brand' => $brand,
]);
}
#[Route('/{id}/edit', name: 'brand_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Brand $brand, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(BrandType::class, $brand);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('brand_index', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('brand/edit.html.twig', [
'brand' => $brand,
'form' => $form,
]);
}
#[Route('/{id}', name: 'brand_delete', methods: ['POST'])]
public function delete(Request $request, Brand $brand, EntityManagerInterface $entityManager): Response
{
if ($this->isCsrfTokenValid('delete'.$brand->getId(), $request->request->get('_token'))) {
$entityManager->remove($brand);
$entityManager->flush();
}
return $this->redirectToRoute('brand_index', [], Response::HTTP_SEE_OTHER);
}
}

View File

@ -0,0 +1,89 @@
<?php
namespace App\Controller;
use App\Entity\GpuCore;
use App\Form\GPUCoreType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[Route('/gpu-core')]
class GpuCoreController extends AbstractController
{
#[Route('/', name: 'gpu-core_index', methods: ['GET'])]
public function index(EntityManagerInterface $entityManager): Response
{
$gPUCores = $entityManager
->getRepository(GpuCore::class)
->findBy([], [
'brand' => 'asc',
'architecture' => 'asc',
'name' => 'asc',
'variant' => 'asc',
]);
return $this->render('gpu_core/index.html.twig', [
'gpu_cores' => $gPUCores,
]);
}
#[Route('/new', name: 'gpu-core_new', methods: ['GET', 'POST'])]
public function new(Request $request, EntityManagerInterface $entityManager): Response
{
$gPUCore = new GpuCore();
$form = $this->createForm(GPUCoreType::class, $gPUCore);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->persist($gPUCore);
$entityManager->flush();
return $this->redirectToRoute('gpu-core_index', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('gpu_core/new.html.twig', [
'gpu_core' => $gPUCore,
'form' => $form,
]);
}
#[Route('/{id}', name: 'gpu-core_show', methods: ['GET'])]
public function show(GpuCore $gPUCore): Response
{
return $this->render('gpu_core/show.html.twig', [
'gpu_core' => $gPUCore,
]);
}
#[Route('/{id}/edit', name: 'gpu-core_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, GpuCore $gPUCore, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(GPUCoreType::class, $gPUCore);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('gpu-core_index', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('gpu_core/edit.html.twig', [
'gpu_core' => $gPUCore,
'form' => $form,
]);
}
#[Route('/{id}', name: 'gpu-core_delete', methods: ['POST'])]
public function delete(Request $request, GpuCore $gPUCore, EntityManagerInterface $entityManager): Response
{
if ($this->isCsrfTokenValid('delete'.$gPUCore->getId(), $request->request->get('_token'))) {
$entityManager->remove($gPUCore);
$entityManager->flush();
}
return $this->redirectToRoute('gpu-core_index', [], Response::HTTP_SEE_OTHER);
}
}

View File

@ -7,7 +7,7 @@ use Doctrine\ORM\Mapping as ORM;
/** /**
* Battery Type * Battery Type
*/ */
#[ORM\Table(name: 'battery_type', schema: 'camera')] #[ORM\Table(name: 'battery_type', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
class BatteryType class BatteryType
{ {
@ -15,4 +15,9 @@ class BatteryType
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')] #[ORM\GeneratedValue(strategy: 'IDENTITY')]
private int $id; private int $id;
public function getId(): ?int
{
return $this->id;
}
} }

View File

@ -0,0 +1,43 @@
<?php declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'brand', schema: 'collection')]
#[ORM\Entity]
class Brand
{
use GetSetTrait;
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'brand_id_seq', allocationSize: 1, initialValue: 1)]
private int $id;
#[ORM\Column(name: 'name', unique: true, nullable: FALSE)]
private string $name;
public function __toString(): string
{
return $this->name;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
}

View File

@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
/** /**
* Camera * Camera
*/ */
#[ORM\Table(name: 'camera', schema: 'camera')] #[ORM\Table(name: 'camera', schema: 'collection')]
#[ORM\Index(columns: ['type_id'], name: 'IDX_747C826FC54C8C93')] #[ORM\Index(columns: ['type_id'], name: 'IDX_747C826FC54C8C93')]
#[ORM\Entity(repositoryClass: CameraRepository::class)] #[ORM\Entity(repositoryClass: CameraRepository::class)]
class Camera class Camera
@ -20,4 +20,9 @@ class Camera
#[ORM\GeneratedValue(strategy: 'IDENTITY')] #[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'camera__id_seq', allocationSize: 1, initialValue: 1)] #[ORM\SequenceGenerator(sequenceName: 'camera__id_seq', allocationSize: 1, initialValue: 1)]
private int $id; private int $id;
public function getId(): ?int
{
return $this->id;
}
} }

View File

@ -2,13 +2,14 @@
namespace App\Entity; namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Stringable; use Stringable;
/** /**
* CameraType * CameraType
*/ */
#[ORM\Table(name: 'camera_type', schema: 'camera')] #[ORM\Table(name: 'camera_type', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
class CameraType implements Stringable class CameraType implements Stringable
{ {

View File

@ -2,12 +2,13 @@
namespace App\Entity; namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* Camera * Camera
*/ */
#[ORM\Table(name: 'film', schema: 'camera')] #[ORM\Table(name: 'film', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
class Film class Film
{ {

View File

@ -4,7 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'film_format', schema: 'camera')] #[ORM\Table(name: 'film_format', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
class FilmFormat class FilmFormat
{ {

View File

@ -7,7 +7,7 @@ use Doctrine\ORM\Mapping as ORM;
/** /**
* Camera.flash * Camera.flash
*/ */
#[ORM\Table(name: 'flash', schema: 'camera')] #[ORM\Table(name: 'flash', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
class Flash class Flash
{ {
@ -24,4 +24,33 @@ class Flash
#[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: FALSE, options: ['default' => FALSE])] #[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: FALSE, options: ['default' => FALSE])]
private bool $formerlyOwned = FALSE; private bool $formerlyOwned = FALSE;
public function getId(): ?int
{
return $this->id;
}
public function isReceived(): ?bool
{
return $this->received;
}
public function setReceived(bool $received): self
{
$this->received = $received;
return $this;
}
public function isFormerlyOwned(): ?bool
{
return $this->formerlyOwned;
}
public function setFormerlyOwned(bool $formerlyOwned): self
{
$this->formerlyOwned = $formerlyOwned;
return $this;
}
} }

View File

View File

View File

@ -0,0 +1,33 @@
<?php declare(strict_types=1);
namespace App\Entity;
trait GetSetTrait {
public function __call(string $name, array $arguments): mixed
{
if (method_exists($this, $name))
{
return $this->$name(...$arguments);
}
// Apparently Doctrine first tries the method with the same
// name as the property, instead of with the get prefix
if (property_exists($this, $name) && empty($arguments))
{
return $this->$name;
}
if (str_starts_with('set', $name))
{
$var = lcfirst(str_replace('set', '', $name));
if (property_exists($this, $var))
{
$this->$name = $arguments[0];
}
return $this;
}
throw new \InvalidArgumentException("Undefined method: {$name}");
}
}

131
src/Entity/Gpu.php Normal file
View File

@ -0,0 +1,131 @@
<?php declare(strict_types=1);
namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'gpu', schema: 'collection')]
#[ORM\Entity]
class Gpu
{
use GetSetTrait;
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
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\JoinColumn(name: 'gpu_brand_id', referencedColumnName: 'id', nullable: FALSE)]
private readonly Brand $gpuBrand;
#[ORM\ManyToOne(targetEntity: 'GpuCore')]
#[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\Column(name: 'alternate_model_name', nullable: TRUE)]
private readonly string $alternateModelName;
#[ORM\Column(name: 'count', nullable: FALSE)]
private readonly int $count;
#[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)]
private readonly string $notes;
public function getId(): ?int
{
return $this->id;
}
public function getModelName(): ?string
{
return $this->modelName;
}
public function setModelName(string $modelName): self
{
$this->modelName = $modelName;
return $this;
}
public function getAlternateModelName(): ?string
{
return $this->alternateModelName;
}
public function setAlternateModelName(?string $alternateModelName): self
{
$this->alternateModelName = $alternateModelName;
return $this;
}
public function getCount(): ?int
{
return $this->count;
}
public function setCount(int $count): self
{
$this->count = $count;
return $this;
}
public function getNotes(): ?string
{
return $this->notes;
}
public function setNotes(?string $notes): self
{
$this->notes = $notes;
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;
}
public function setGpuBrand(?Brand $gpuBrand): self
{
$this->gpuBrand = $gpuBrand;
return $this;
}
public function getGpuCore(): ?GpuCore
{
return $this->gpuCore;
}
public function setGpuCore(?GpuCore $gpuCore): self
{
$this->gpuCore = $gpuCore;
return $this;
}
}

135
src/Entity/GpuCore.php Normal file
View File

@ -0,0 +1,135 @@
<?php declare(strict_types=1);
namespace App\Entity;
use App\Repository\GPURepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'gpu_core', schema: 'collection')]
#[ORM\Entity]
class GpuCore
{
use GetSetTrait;
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private int $id;
#[ORM\ManyToOne(targetEntity: 'Brand')]
#[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id')]
private Brand $brand;
#[ORM\Column(name: 'name')]
private readonly string $name;
#[ORM\Column(name: 'variant', nullable: TRUE)]
private readonly ?string $variant;
#[ORM\Column(name: 'generation_name')]
private readonly string $generationName;
#[ORM\Column(name: 'architecture')]
private readonly string $architecture;
#[ORM\Column(name: 'architecture_link')]
private readonly string $architectureLink;
#[ORM\Column(name: 'process_node', nullable: TRUE)]
private readonly ?int $processNode;
public function __toString(): string
{
return "$this->brand $this->name ($this->variant/$this->generationName)";
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getVariant(): ?string
{
return $this->variant;
}
public function setVariant(string $variant): self
{
$this->variant = $variant;
return $this;
}
public function getGenerationName(): ?string
{
return $this->generationName;
}
public function setGenerationName(string $generationName): self
{
$this->generationName = $generationName;
return $this;
}
public function getArchitecture(): ?string
{
return $this->architecture;
}
public function setArchitecture(string $architecture): self
{
$this->architecture = $architecture;
return $this;
}
public function getArchitectureLink(): ?string
{
return $this->architectureLink;
}
public function setArchitectureLink(string $architectureLink): self
{
$this->architectureLink = $architectureLink;
return $this;
}
public function getProcessNode(): ?int
{
return $this->processNode;
}
public function setProcessNode(int $processNode): self
{
$this->processNode = $processNode;
return $this;
}
public function getBrand(): ?Brand
{
return $this->brand;
}
public function setBrand(?Brand $brand): self
{
$this->brand = $brand;
return $this;
}
}

View File

@ -7,6 +7,7 @@ use Doctrine\ORM\Mapping as ORM;
trait LensTrait trait LensTrait
{ {
use PurchasePriceTrait; use PurchasePriceTrait;
use GetSetTrait;
#[ORM\Column(name: 'brand', type: 'string', length: 64, nullable: TRUE)] #[ORM\Column(name: 'brand', type: 'string', length: 64, nullable: TRUE)]
private readonly ?string $brand; private readonly ?string $brand;
@ -61,444 +62,4 @@ trait LensTrait
#[ORM\Column(name: 'aperture_blades', type: 'smallint', nullable: TRUE)] #[ORM\Column(name: 'aperture_blades', type: 'smallint', nullable: TRUE)]
private readonly ?int $apertureBlades; private readonly ?int $apertureBlades;
/**
* Get id
*/
public function getId(): int
{
return $this->id;
}
/**
* Set brand
*
* @param string $brand
*/
public function setBrand($brand): self
{
$this->brand = $brand;
return $this;
}
/**
* Get brand
*
* @return string
*/
public function getBrand()
{
return $this->brand;
}
/**
* Set coatings
*
* @param string $coatings
*/
public function setCoatings($coatings): self
{
$this->coatings = $coatings;
return $this;
}
/**
* Get coatings
*
* @return string
*/
public function getCoatings()
{
return $this->coatings;
}
/**
* Set productLine
*
* @param string $productLine
*/
public function setProductLine($productLine): self
{
$this->productLine = $productLine;
return $this;
}
/**
* Get productLine
*
* @return string
*/
public function getProductLine()
{
return $this->productLine;
}
/**
* Set model
*
* @param string $model
*/
public function setModel($model): self
{
$this->model = $model;
return $this;
}
/**
* Get model
*
* @return string
*/
public function getModel()
{
return $this->model;
}
/**
* Set minFStop
*
* @param string $minFStop
*/
public function setMinFStop($minFStop): self
{
$this->minFStop = $minFStop;
return $this;
}
/**
* Get minFStop
*
* @return string
*/
public function getMinFStop()
{
return $this->minFStop;
}
/**
* Set maxFStop
*
* @param float $maxFStop
*/
public function setMaxFStop($maxFStop): self
{
$this->maxFStop = $maxFStop;
return $this;
}
/**
* Get maxFStop
*
* @return float
*/
public function getMaxFStop()
{
return $this->maxFStop;
}
/**
* Set minFocalLength
*
* @param int $minFocalLength
*/
public function setMinFocalLength($minFocalLength): self
{
$this->minFocalLength = $minFocalLength;
return $this;
}
/**
* Get minFocalLength
*
* @return int
*/
public function getMinFocalLength()
{
return $this->minFocalLength;
}
/**
* Set maxFocalLength
*
* @param int $maxFocalLength
*/
public function setMaxFocalLength($maxFocalLength): self
{
$this->maxFocalLength = $maxFocalLength;
return $this;
}
/**
* Get maxFocalLength
*
* @return int
*/
public function getMaxFocalLength()
{
return $this->maxFocalLength;
}
/**
* Set serial
*
* @param string $serial
*/
public function setSerial($serial): self
{
$this->serial = $serial;
return $this;
}
/**
* Get serial
*/
public function getSerial(): string
{
return $this->serial ?? '';
}
/**
* Set notes
*
* @param string $notes
*/
public function setNotes(?string $notes): self
{
$this->notes = $notes;
return $this;
}
/**
* Get notes
*/
public function getNotes(): string
{
return $this->notes ?? '';
}
/**
* Get image size
*/
public function getImageSize(): string
{
return $this->imageSize;
}
/**
* Set image size
*/
public function setImageSize(string $imageSize): self
{
$this->imageSize = $imageSize;
return $this;
}
/**
* Set mount
*
* @param string $mount
*/
public function setMount($mount): self
{
$this->mount = $mount;
return $this;
}
/**
* Get mount
*
* @return string
*/
public function getMount()
{
return $this->mount;
}
/**
* Set received
*
* @param bool $received
*/
public function setReceived($received): self
{
$this->received = $received;
return $this;
}
/**
* Get received
*
* @return bool
*/
public function getReceived()
{
return $this->received;
}
/**
* Set formerlyOwned
*
* @param bool $formerlyOwned
*/
public function setFormerlyOwned($formerlyOwned): self
{
$this->formerlyOwned = $formerlyOwned;
return $this;
}
/**
* Get formerlyOwned
*
* @return bool
*/
public function getFormerlyOwned()
{
return $this->formerlyOwned;
}
/**
* Set frontFilterSize
*
* @param string $frontFilterSize
*/
public function setFrontFilterSize($frontFilterSize): self
{
$this->frontFilterSize = $frontFilterSize;
return $this;
}
/**
* Get frontFilterSize
*
* @return string
*/
public function getFrontFilterSize()
{
return $this->frontFilterSize;
}
/**
* Set rearFilterSize
*
* @param string $rearFilterSize
*/
public function setRearFilterSize($rearFilterSize): self
{
$this->rearFilterSize = $rearFilterSize;
return $this;
}
/**
* Get rearFilterSize
*
* @return string
*/
public function getRearFilterSize()
{
return $this->rearFilterSize;
}
/**
* Set isTeleconverter
*
* @param bool $isTeleconverter
*/
public function setIsTeleconverter($isTeleconverter): self
{
$this->isTeleconverter = $isTeleconverter;
return $this;
}
/**
* Get isTeleconverter
*
* @return bool
*/
public function getIsTeleconverter()
{
return $this->isTeleconverter;
}
/**
* Set designElements
*
* @param int $designElements
*/
public function setDesignElements($designElements): self
{
$this->designElements = $designElements;
return $this;
}
/**
* Get designElements
*
* @return int
*/
public function getDesignElements()
{
return $this->designElements;
}
/**
* Set designGroups
*
* @param int $designGroups
*/
public function setDesignGroups($designGroups): self
{
$this->designGroups = $designGroups;
return $this;
}
/**
* Get designGroups
*
* @return int
*/
public function getDesignGroups()
{
return $this->designGroups;
}
/**
* Set apertureBlades
*
* @param int $apertureBlades
*/
public function setApertureBlades($apertureBlades): self
{
$this->apertureBlades = $apertureBlades;
return $this;
}
/**
* Get apertureBlades
*
* @return int
*/
public function getApertureBlades(): ?int
{
return $this->apertureBlades;
}
} }

View File

@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
/** /**
* Camera.lenses * Camera.lenses
*/ */
#[ORM\Table(name: 'lenses', schema: 'camera')] #[ORM\Table(name: 'lenses', schema: 'collection')]
#[ORM\Entity(repositoryClass: LensesRepository::class)] #[ORM\Entity(repositoryClass: LensesRepository::class)]
class Lenses class Lenses
{ {
@ -25,4 +25,33 @@ class Lenses
#[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: FALSE)] #[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: FALSE)]
private bool $formerlyOwned = FALSE; private bool $formerlyOwned = FALSE;
public function getId(): ?int
{
return $this->id;
}
public function isReceived(): ?bool
{
return $this->received;
}
public function setReceived(bool $received): self
{
$this->received = $received;
return $this;
}
public function isFormerlyOwned(): ?bool
{
return $this->formerlyOwned;
}
public function setFormerlyOwned(bool $formerlyOwned): self
{
$this->formerlyOwned = $formerlyOwned;
return $this;
}
} }

View File

@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
/** /**
* Camera.previouslyOwnedCamera * Camera.previouslyOwnedCamera
*/ */
#[ORM\Table(name: 'previously_owned_camera', schema: 'camera')] #[ORM\Table(name: 'previously_owned_camera', schema: 'collection')]
#[ORM\Index(name: 'IDX_6EF94C6BC54C8C93', columns: ['type_id'])] #[ORM\Index(name: 'IDX_6EF94C6BC54C8C93', columns: ['type_id'])]
#[ORM\Entity(repositoryClass: CameraRepository::class)] #[ORM\Entity(repositoryClass: CameraRepository::class)]
class PreviouslyOwnedCamera class PreviouslyOwnedCamera
@ -20,4 +20,9 @@ class PreviouslyOwnedCamera
#[ORM\GeneratedValue(strategy: 'IDENTITY')] #[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'prevously_owned_camera_id_seq', allocationSize: 1, initialValue: 1)] #[ORM\SequenceGenerator(sequenceName: 'prevously_owned_camera_id_seq', allocationSize: 1, initialValue: 1)]
private int $id; private int $id;
public function getId(): ?int
{
return $this->id;
}
} }

View File

@ -7,7 +7,7 @@ use Doctrine\ORM\Mapping as ORM;
/** /**
* Camera.flash * Camera.flash
*/ */
#[ORM\Table(name: 'previously_owned_flash', schema: 'camera')] #[ORM\Table(name: 'previously_owned_flash', schema: 'collection')]
#[ORM\Entity] #[ORM\Entity]
class PreviouslyOwnedFlash class PreviouslyOwnedFlash
{ {
@ -23,4 +23,33 @@ class PreviouslyOwnedFlash
#[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: FALSE, options: ['default' => TRUE])] #[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: FALSE, options: ['default' => TRUE])]
private bool $formerlyOwned = TRUE; private bool $formerlyOwned = TRUE;
public function getId(): ?int
{
return $this->id;
}
public function isReceived(): ?bool
{
return $this->received;
}
public function setReceived(bool $received): self
{
$this->received = $received;
return $this;
}
public function isFormerlyOwned(): ?bool
{
return $this->formerlyOwned;
}
public function setFormerlyOwned(bool $formerlyOwned): self
{
$this->formerlyOwned = $formerlyOwned;
return $this;
}
} }

View File

@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
/** /**
* Camera.previouslyOwnedLenses * Camera.previouslyOwnedLenses
*/ */
#[ORM\Table(name: 'previously_owned_lenses', schema: 'camera')] #[ORM\Table(name: 'previously_owned_lenses', schema: 'collection')]
#[ORM\Entity(repositoryClass: LensesRepository::class)] #[ORM\Entity(repositoryClass: LensesRepository::class)]
class PreviouslyOwnedLenses class PreviouslyOwnedLenses
{ {
@ -24,4 +24,33 @@ class PreviouslyOwnedLenses
#[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: FALSE)] #[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: FALSE)]
private bool $formerlyOwned = TRUE; private bool $formerlyOwned = TRUE;
public function getId(): ?int
{
return $this->id;
}
public function isReceived(): ?bool
{
return $this->received;
}
public function setReceived(bool $received): self
{
$this->received = $received;
return $this;
}
public function isFormerlyOwned(): ?bool
{
return $this->formerlyOwned;
}
public function setFormerlyOwned(bool $formerlyOwned): self
{
$this->formerlyOwned = $formerlyOwned;
return $this;
}
} }

25
src/Form/BrandType.php Normal file
View File

@ -0,0 +1,25 @@
<?php
namespace App\Form;
use App\Entity\Brand;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class BrandType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name')
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Brand::class,
]);
}
}

31
src/Form/GPUCoreType.php Normal file
View File

@ -0,0 +1,31 @@
<?php
namespace App\Form;
use App\Entity\GpuCore;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class GPUCoreType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('brand')
->add('name')
->add('variant')
->add('architecture')
->add('architectureLink')
->add('generationName')
->add('processNode')
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => GpuCore::class,
]);
}
}

View File

@ -0,0 +1,13 @@
<?php declare(strict_types=1);
namespace App\Types;
enum BusInterface: string {
case PCI = 'PCI';
case ISA = 'ISA';
case VLB = 'VLB (Vesa Local Bus)';
case AGP = 'AGP';
case AGPX2 = 'AGP 2x';
case AGPX4 = 'AGP 4x';
case AGPX8 = 'AGP 8x';
}

View File

@ -0,0 +1,30 @@
{% extends 'form.html.twig' %}
{% block title %}Brands - Edit{% endblock %}
{% block form %}
<h1>Edit Brand</h1>
<div class="small callout">
<ul>
<li>
<a href="{{ path('brand_index') }}">Back to the list</a>
</li>
</ul>
</div>
<div class="large primary callout">
{{ form_start(form) }}
{{ form_widget(form) }}
<button
type="submit"
class="success button expanded"
>Update</button>
{{ form_end(form) }}
<form method="post" action="{{ path('brand_delete', {'id': brand.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ brand.id) }}">
<button type="submit" class="alert button expanded">Delete</button>
</form>
</div>
{% endblock %}

View File

@ -0,0 +1,47 @@
{% extends 'form.html.twig' %}
{% block title %}Brands{% endblock %}
{% block form %}
<h2>Brands</h2>
<div class="small callout primary">
<ul>
<li>
<a href="{{ path('brand_new') }}">Add a Brand</a>
</li>
</ul>
</div>
<table class="hover scroll sortable stack">
<thead>
<tr>
<th>Actions</th>
<th>Id</th>
<th>Name</th>
</tr>
</thead>
<tbody>
{% for brand in brands %}
<tr>
<td>
<ul>
<li>
<a href="{{ path('brand_show', {'id': brand.id}) }}">View 👁</a>
</li>
<li>
<a href="{{ path('brand_edit', {'id': brand.id}) }}">Edit <span class="edit-icon">&#9998;</span></a>
</li>
</ul>
</td>
<td>{{ brand.id }}</td>
<td>{{ brand.name }}</td>
</tr>
{% else %}
<tr>
<td colspan="3">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -0,0 +1,23 @@
{% extends 'form.html.twig' %}
{% block title %}Brands - New{% endblock %}
{% block form %}
<h1>Create new Brand</h1>
<div class="small callout">
<ul>
<li>
<a href="{{ path('brand_index') }}">Back to the list</a>
</li>
</ul>
</div>
<div class="large primary callout">
{{ form_start(form) }}
{{ form_widget(form) }}
<button type="submit" class="success button expanded">Add</button>
{{ form_end(form) }}
</div>
{% endblock %}

View File

@ -0,0 +1,42 @@
{% extends 'form.html.twig' %}
{% block title %}Brand{% endblock %}
{% block form %}
<h2>Brand</h2>
<div class="callout">
<ul>
<li>
<a href="{{ path('brand_index') }}">Back to the list</a>
</li>
<li>
<a href="{{ path('brand_edit', { 'id': brand.id }) }}">Edit</a>
</li>
</ul>
<hr />
<form method="post" action="{{ path('brand_delete', {'id': brand.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ brand.id) }}">
<button type="submit" class="alert button expanded">Delete</button>
</form>
</div>
<div class="large primary callout">
<table class="table">
<tbody>
<tr>
<th>Id</th>
<td>{{ brand.id }}</td>
</tr>
<tr>
<th>Name</th>
<td>{{ brand.name }}</td>
</tr>
</tbody>
</table>
</div>
{% endblock %}

View File

@ -0,0 +1,4 @@
<form method="post" action="{{ path('gpu-core_delete', {'id': gpu_core.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ gpu_core.id) }}">
<button type="submit" class="alert button expanded">Delete</button>
</form>

View File

@ -0,0 +1,4 @@
{{ form_start(form) }}
{{ form_widget(form) }}
<button type="submit" class="success button expanded">{{ button_label|default('Save') }}</button>
{{ form_end(form) }}

View File

@ -0,0 +1,21 @@
{% extends 'form.html.twig' %}
{% block title %}GPU Core - Edit{% endblock %}
{% block form %}
<h1>Edit GPU Core</h1>
<div class="small callout">
<ul>
<li>
<a href="{{ path('gpu-core_index') }}">Back to the list</a>
</li>
</ul>
</div>
<div class="large primary callout">
{{ include('gpu_core/_form.html.twig', {'button_label': 'Update'}) }}
{{ include('gpu_core/_delete_form.html.twig') }}
</div>
{% endblock %}

View File

@ -0,0 +1,58 @@
{% extends 'base.html.twig' %}
{% block title %}GPU Cores{% endblock %}
{% block body %}
<h2>GPU Cores</h2>
<div class="small callout primary">
<ul>
<li>
<a href="{{ path('gpu-core_new') }}">Add a GPU Core</a>
</li>
</ul>
</div>
<table class="hover scroll sortable stack">
<thead>
<tr>
<th>Actions</th>
<th>Id</th>
<th>Brand</th>
<th>Name</th>
<th>Variant</th>
<th>GenerationName</th>
<th>Architecture</th>
<th>ProcessNode</th>
</tr>
</thead>
<tbody>
{% for gpu_core in gpu_cores %}
<tr>
<td>
<ul>
<li>
<a href="{{ path('gpu-core_show', {'id': gpu_core.id}) }}">View 👁</a>
</li>
<li>
<a href="{{ path('gpu-core_edit', {'id': gpu_core.id}) }}">Edit <span class="edit-icon">&#9998;</span></a>
</li>
</ul>
</td>
<td>{{ gpu_core.id }}</td>
<td>{{ gpu_core.brand.name }}</td>
<td>{{ gpu_core.name }}</td>
<td>{{ gpu_core.variant }}</td>
<td>{{ gpu_core.generationName }}</td>
<td><a href="{{ gpu_core.architectureLink }}">{{ gpu_core.architecture }}</a></td>
<td>{{ gpu_core.processNode }}nm</td>
</tr>
{% else %}
<tr>
<td colspan="8">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -0,0 +1,19 @@
{% extends 'form.html.twig' %}
{% block title %}GPU Core - {% endblock %}
{% block form %}
<h2>Create new GPU Core</h2>
<div class="small callout">
<ul>
<li>
<a href="{{ path('gpu-core_index') }}">Back to the list</a>
</li>
</ul>
</div>
<div class="large primary callout">
{{ include('gpu_core/_form.html.twig') }}
</div>
{% endblock %}

View File

@ -0,0 +1,58 @@
{% extends 'form.html.twig' %}
{% block title %}GPU Core{% endblock %}
{% block form %}
<h2>GPU Core</h2>
<div class="callout">
<ul>
<li>
<a href="{{ path('gpu-core_index') }}">Back to the list</a>
</li>
<li>
<a href="{{ path('gpu-core_edit', { 'id': gpu_core.id }) }}">Edit</a>
</li>
</ul>
<hr />
<form method="post" action="{{ path('gpu-core_delete', {'id': gpu_core.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ gpu_core.id) }}">
<button type="submit" class="alert button expanded">Delete</button>
</form>
</div>
<div class="large primary callout">
<table class="table">
<tbody>
<tr>
<th>Id</th>
<td>{{ gpu_core.id }}</td>
</tr>
<tr>
<th>Name</th>
<td>{{ gpu_core.name }}</td>
</tr>
<tr>
<th>Variant</th>
<td>{{ gpu_core.variant }}</td>
</tr>
<tr>
<th>GenerationName</th>
<td>{{ gpu_core.generationName }}</td>
</tr>
<tr>
<th>Architecture</th>
<td><a href="{{ gpu_core.architectureLink }}">{{ gpu_core.architecture }}</a></td>
</tr>
<tr>
<th>ProcessNode</th>
<td>{{ gpu_core.processNode }}nm</td>
</tr>
</tbody>
</table>
</div>
{% endblock %}

View File

@ -1,4 +1,4 @@
<h1>Camera Collection CRUD</h1> <h1>Collection CRUD</h1>
<div class="top-bar"> <div class="top-bar">
<div class="top-bar-left"> <div class="top-bar-left">
<ul class="menu"> <ul class="menu">
@ -13,6 +13,12 @@
<a href="{{ path('lens_index') }}">🔎 Lenses</a> <a href="{{ path('lens_index') }}">🔎 Lenses</a>
</li> </li>
</ul> </ul>
<ul class="menu">
<li class="menu-text">Computer Components</li>
<li class="{{ route starts with 'gpu-core' ? 'is-active' }}">
<a href="{{ path('gpu-core_index') }}">🌀 GPU Cores</a>
</li>
</ul>
<ul class="menu"> <ul class="menu">
<li class="menu-text">Previously Owned</li> <li class="menu-text">Previously Owned</li>
<li class="{{ route starts with 'previously-owned-camera' ? 'is-active' }}"> <li class="{{ route starts with 'previously-owned-camera' ? 'is-active' }}">
@ -27,6 +33,9 @@
</ul> </ul>
<ul class="menu"> <ul class="menu">
<li class="menu-text">Meta</li> <li class="menu-text">Meta</li>
<li class="{{ route starts with 'brand_' ? 'is-active' }}">
<a href="{{ path('brand_index') }}">🕺Brands</a>
</li>
<li class="{{ route starts with 'film_' ? 'is-active' }}"> <li class="{{ route starts with 'film_' ? 'is-active' }}">
<a href="{{ path('film_index') }}">🎞️ Film</a> <a href="{{ path('film_index') }}">🎞️ Film</a>
</li> </li>