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:
1 parent
41aca6215e
commit
830a950bf4
16 files changed
+2073
-15
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user