diff --git a/src/Controllers/TicketController.php b/src/Controllers/TicketController.php index 63285e9..3dfa05e 100644 --- a/src/Controllers/TicketController.php +++ b/src/Controllers/TicketController.php @@ -9,6 +9,15 @@ use BitGoblin\Goliath\Models\Ticket; class TicketController extends Controller { + public function getView(Request $request, Response $response, array $args): Response { + $ticket = Ticket::where('id', $args['ticket_id'])->get(); + + $view = Twig::fromRequest($request); + return $view->render($response, 'ticket/view.twig', [ + 'ticket' => $ticket[0], + ]); + } + public function getCreate(Request $request, Response $response): Response { $view = Twig::fromRequest($request); return $view->render($response, 'ticket/create.twig'); diff --git a/src/routes.php b/src/routes.php index ba7be91..2f1de9f 100644 --- a/src/routes.php +++ b/src/routes.php @@ -10,3 +10,6 @@ $app->get('/', '\\BitGoblin\\Goliath\\Controllers\\HomeController:getIndex')->se // /ticket/create GET route - allows a user to fill out a form to create a ticket $app->get('/ticket/create', '\\BitGoblin\\Goliath\\Controllers\\TicketController:getCreate')->setName('ticket.create'); $app->post('/ticket/create', '\\BitGoblin\\Goliath\\Controllers\\TicketController:postCreate'); + +// /ticket/id route - displays ticket info to user +$app->get('/ticket/{ticket_id}', '\\BitGoblin\\Goliath\\Controllers\\TicketController:getView')->setName('ticket.view'); diff --git a/views/index.twig b/views/index.twig index 4f5f8e9..85196ba 100644 --- a/views/index.twig +++ b/views/index.twig @@ -19,7 +19,7 @@
{% for ticket in tickets %} -{{ ticket.body }}
+