Added a ticket view route
This commit is contained in:
parent
830a950bf4
commit
95bf9250e7
@ -9,6 +9,15 @@ use BitGoblin\Goliath\Models\Ticket;
|
|||||||
|
|
||||||
class TicketController extends Controller {
|
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 {
|
public function getCreate(Request $request, Response $response): Response {
|
||||||
$view = Twig::fromRequest($request);
|
$view = Twig::fromRequest($request);
|
||||||
return $view->render($response, 'ticket/create.twig');
|
return $view->render($response, 'ticket/create.twig');
|
||||||
|
@ -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
|
// /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->get('/ticket/create', '\\BitGoblin\\Goliath\\Controllers\\TicketController:getCreate')->setName('ticket.create');
|
||||||
$app->post('/ticket/create', '\\BitGoblin\\Goliath\\Controllers\\TicketController:postCreate');
|
$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');
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for ticket in tickets %}
|
{% for ticket in tickets %}
|
||||||
<td>{{ ticket.title }}</td>
|
<td><a href="{{ url_for('ticket.view', {ticket_id: ticket.id}) }}">{{ ticket.title }}</a></td>
|
||||||
<td>{{ ticket.severity }}</td>
|
<td>{{ ticket.severity }}</td>
|
||||||
<td>{{ ticket.due_at }}</td>
|
<td>{{ ticket.due_at }}</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
20
views/ticket/view.twig
Normal file
20
views/ticket/view.twig
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{% extends 'layout.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Home{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="columns twelve">
|
||||||
|
<h1>{{ ticket.title }}</h1>
|
||||||
|
<h5 class="ticket-created">Created at {{ ticket.created_at }} | Last updated at {{ ticket.updated_at }}</h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="columns twelve">
|
||||||
|
<p>{{ ticket.body }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user