39 lines
939 B
PHP
39 lines
939 B
PHP
<?php
|
|
|
|
namespace Blog\Controller;
|
|
|
|
use Blog\Model\TicketModel;
|
|
|
|
class TicketController {
|
|
|
|
private $ticketModel;
|
|
private $view;
|
|
|
|
public function __construct($view) {
|
|
$this->ticketModel = new TicketModel();
|
|
$this->view = $view;
|
|
}
|
|
|
|
public function showTickets() {
|
|
$tickets = $this->ticketModel->getTickets();
|
|
$this->view->setVars(['tickets' => $tickets]);
|
|
}
|
|
|
|
public function buyTicket() {
|
|
$data = [
|
|
'user_id' => $_POST['user_id'] ?? null,
|
|
'event_id' => $_POST['event_id'] ?? null,
|
|
'price' => $_POST['price'] ?? null
|
|
];
|
|
|
|
$result = $this->ticketModel->createTicket($data);
|
|
$this->view->setVars(['ticket' => $result]);
|
|
}
|
|
|
|
public function deleteTicket() {
|
|
$ticketid = $_GET['ticketid'] ?? null;
|
|
if ($ticketid) {
|
|
$this->ticketModel->deleteTicket($ticketid);
|
|
}
|
|
}
|
|
} |