Added Eloquent and Phinx for handling database connections and migrations; added a Ticket model and a simple ticket/create form to create new tickets

This commit is contained in:
2022-11-20 22:25:29 -05:00
parent 41aca6215e
commit 830a950bf4
16 changed files with 2073 additions and 15 deletions

View File

@ -0,0 +1,34 @@
<?php
namespace BitGoblin\Goliath\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Views\Twig;
use BitGoblin\Goliath\Models\Ticket;
class TicketController extends Controller {
public function getCreate(Request $request, Response $response): Response {
$view = Twig::fromRequest($request);
return $view->render($response, 'ticket/create.twig');
}
public function postCreate(Request $request, Response $response): Response {
$params = (array)$request->getParsedBody();
$ticket = new Ticket;
$ticket->title = $params['ticket_title'];
$ticket->body = $params['ticket_body'];
$ticket->severity = $params['ticket_severity'];
$ticket->due_at = $params['ticket_due'];
$ticket->save();
// redirect the user back to the home page
return $response
->withHeader('Location', '/')
->withStatus(302);
}
}