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.title }} + {{ ticket.title }} {{ ticket.severity }} {{ ticket.due_at }} {% endfor %} diff --git a/views/ticket/view.twig b/views/ticket/view.twig new file mode 100644 index 0000000..201e29b --- /dev/null +++ b/views/ticket/view.twig @@ -0,0 +1,20 @@ +{% extends 'layout.twig' %} + +{% block title %}Home{% endblock %} + +{% block content %} +
+
+

{{ ticket.title }}

+
Created at {{ ticket.created_at }} | Last updated at {{ ticket.updated_at }}
+
+
+ +
+ +
+
+

{{ ticket.body }}

+
+
+{% endblock %}