rofl
This commit is contained in:
parent
b052697417
commit
43ca79f650
14 changed files with 292 additions and 57 deletions
|
@ -28,7 +28,7 @@ final class DrinkTypeController extends AbstractController
|
|||
#[Route(path: '/new', name: 'app_drink_type_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$drinkType = new DrinkType('', '');
|
||||
$drinkType = new DrinkType();
|
||||
$form = $this->createForm(DrinkTypeForm::class, $drinkType);
|
||||
$form->handleRequest($request);
|
||||
|
||||
|
|
81
src/Controller/InventoryRecordController.php
Normal file
81
src/Controller/InventoryRecordController.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\InventoryRecord;
|
||||
use App\Form\InventoryRecordForm;
|
||||
use App\Repository\InventoryRecordRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
#[Route('/inventory-record')]
|
||||
final class InventoryRecordController extends AbstractController
|
||||
{
|
||||
#[Route(name: 'app_inventory_record_index', methods: ['GET'])]
|
||||
public function index(InventoryRecordRepository $inventoryRecordRepository): Response
|
||||
{
|
||||
return $this->render('inventory_record/index.html.twig', [
|
||||
'inventory_records' => $inventoryRecordRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/new', name: 'app_inventory_record_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$inventoryRecord = new InventoryRecord();
|
||||
$form = $this->createForm(InventoryRecordForm::class, $inventoryRecord);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->persist($inventoryRecord);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_inventory_record_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->render('inventory_record/new.html.twig', [
|
||||
'inventory_record' => $inventoryRecord,
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_inventory_record_show', methods: ['GET'])]
|
||||
public function show(InventoryRecord $inventoryRecord): Response
|
||||
{
|
||||
return $this->render('inventory_record/show.html.twig', [
|
||||
'inventory_record' => $inventoryRecord,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_inventory_record_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, InventoryRecord $inventoryRecord, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(InventoryRecordForm::class, $inventoryRecord);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_inventory_record_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->render('inventory_record/edit.html.twig', [
|
||||
'inventory_record' => $inventoryRecord,
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_inventory_record_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, InventoryRecord $inventoryRecord, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$inventoryRecord->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$entityManager->remove($inventoryRecord);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_inventory_record_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue