Compare commits
2 Commits
830a950bf4
...
c6d4c3df10
Author | SHA1 | Date | |
---|---|---|---|
c6d4c3df10 | |||
95bf9250e7 |
25
db/migrations/20221121043856_add_status_to_tickets_table.php
Normal file
25
db/migrations/20221121043856_add_status_to_tickets_table.php
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
@ -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 %}
|
||||||
|
21
views/ticket/view.twig
Normal file
21
views/ticket/view.twig
Normal 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 %}
|
Loading…
Reference in New Issue
Block a user