Compare commits

...

2 Commits

Author SHA1 Message Date
c6d4c3df10 Added ticket status 2022-11-20 23:42:45 -05:00
95bf9250e7 Added a ticket view route 2022-11-20 23:38:16 -05:00
5 changed files with 59 additions and 1 deletions

View File

@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddStatusToTicketsTable extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('tickets');
$table->addColumn('status', 'string', ['null' => false, 'default' => 'open'])
->update();
}
}

View File

@ -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');

View File

@ -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');

View File

@ -19,7 +19,7 @@
</thead>
<tbody>
{% 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.due_at }}</td>
{% endfor %}

21
views/ticket/view.twig Normal file
View File

@ -0,0 +1,21 @@
{% extends 'layout.twig' %}
{% block title %}Home{% endblock %}
{% block content %}
<div class="row">
<div class="columns twelve">
<h1>{{ ticket.title }}</h1>
<h4 class="ticket-status">Status: {{ ticket.status }}</h4>
<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 %}