[Ivan Diaz] - Ticket comment WIP [skip ci]
This commit is contained in:
parent
e039162025
commit
ea65ea35d1
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
include 'ticket/create.php';
|
||||
include 'ticket/comment.php';
|
||||
|
||||
$ticketControllers = new ControllerGroup();
|
||||
$ticketControllers->setGroupPath('/ticket');
|
||||
|
||||
$ticketControllers->addController(new CreateController);
|
||||
$ticketControllers->addController(new CommentController);
|
||||
|
||||
$ticketControllers->finalize();
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
use RedBeanPHP\Facade as RedBean;
|
||||
|
||||
class CommentController extends Controller {
|
||||
const PATH = '/comment';
|
||||
|
||||
private $ticketId;
|
||||
private $content;
|
||||
|
||||
public function handler() {
|
||||
/*
|
||||
//$this->storeComment();
|
||||
$ticket = RedBean::load('tickets', Controller::request('ticketId'));
|
||||
$comment = RedBean::dispense('comments');
|
||||
$comment->content = Controller::request('content');
|
||||
|
||||
$ticket->ownCommentsList[] = $comment;
|
||||
|
||||
RedBean::store($ticket);
|
||||
$ticket = RedBean::load('tickets', Controller::request('ticketId'));
|
||||
|
||||
$string = "";
|
||||
$string += count($ticket->ownCommentsList);
|
||||
|
||||
foreach( $ticket->ownCommentsList as $comment2 ) {
|
||||
}*/
|
||||
}
|
||||
|
||||
private function storeComment() {
|
||||
$this->ticketId = Controller::request('ticketId');
|
||||
$this->content = Controller::request('content');
|
||||
$ticket = Ticket::getTicket($this->ticketId);
|
||||
|
||||
$comment = new Comment();
|
||||
$comment->setProperties(array(
|
||||
'content' => $this->content
|
||||
//'ticket' => $ticket->getBeanInstance()
|
||||
));
|
||||
|
||||
$ticket->getBeanInstance()->ownCommentsList = [$comment->getBeanInstance()];
|
||||
$ticket->store();
|
||||
$ticket = Ticket::getTicket($this->ticketId);
|
||||
Response::respondError(count($ticket->ownCommentsList));
|
||||
}
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
use RedBeanPHP\Facade as RedBean;
|
||||
|
||||
class CreateController extends Controller {
|
||||
const PATH = '/create';
|
||||
|
||||
private $title ;
|
||||
private $title;
|
||||
private $content;
|
||||
private $departmentId;
|
||||
private $language;
|
||||
|
|
|
@ -20,6 +20,10 @@ class Ticket extends DataStore {
|
|||
);
|
||||
}
|
||||
|
||||
public static function getTicket($value, $property = 'id') {
|
||||
return parent::getDataStore($value, $property);
|
||||
}
|
||||
|
||||
protected function getDefaultProps() {
|
||||
return array();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue