Added ticket deletion; fixed some small issues with the ticket list on the home page

This commit is contained in:
2022-11-21 23:55:19 -05:00
parent 5683c0bc8b
commit f3ac8a6965
5 changed files with 26 additions and 10 deletions

View File

@ -11,7 +11,7 @@ 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()[0];
$ticket = Ticket::where('id', $args['ticket_id'])->first();
$view = Twig::fromRequest($request);
return $view->render($response, 'ticket/view.twig', [
@ -69,4 +69,14 @@ class TicketController extends Controller {
->withStatus(302);
}
public function getDelete(Request $request, Response $response, array $args): Response {
$ticket = Ticket::where('id', $args['ticket_id'])->first();
$ticket->delete();
return $response
->withHeader('Location', '/')
->withStatus(302);
}
}