Ivan - Update ownCommentList logic for tickets [skip ci]
This commit is contained in:
parent
ea65ea35d1
commit
f4450e81de
|
@ -8,38 +8,25 @@ class CommentController extends Controller {
|
|||
private $content;
|
||||
|
||||
public function handler() {
|
||||
/*
|
||||
//$this->storeComment();
|
||||
$ticket = RedBean::load('tickets', Controller::request('ticketId'));
|
||||
$comment = RedBean::dispense('comments');
|
||||
$comment->content = Controller::request('content');
|
||||
$this->requestData();
|
||||
$this->storeComment();
|
||||
|
||||
$ticket->ownCommentsList[] = $comment;
|
||||
Response::respondSuccess();
|
||||
}
|
||||
|
||||
RedBean::store($ticket);
|
||||
$ticket = RedBean::load('tickets', Controller::request('ticketId'));
|
||||
|
||||
$string = "";
|
||||
$string += count($ticket->ownCommentsList);
|
||||
|
||||
foreach( $ticket->ownCommentsList as $comment2 ) {
|
||||
}*/
|
||||
private function requestData() {
|
||||
$this->ticketId = Controller::request('ticketId');
|
||||
$this->content = Controller::request('content');
|
||||
}
|
||||
|
||||
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));
|
||||
$ticket->addComment($comment);
|
||||
$ticket->store();
|
||||
}
|
||||
}
|
|
@ -59,10 +59,11 @@ class CreateController extends Controller {
|
|||
'date' => date("F j, Y, g:i a"),
|
||||
'unread' => false,
|
||||
'closed' => false,
|
||||
'author' => '',
|
||||
'owner'=> '',
|
||||
'ownComments' => []
|
||||
'author' => null,
|
||||
'owner'=> null
|
||||
));
|
||||
$ticket->getBeanInstance()->ownCommentList[] = RedBean::dispense('comment');
|
||||
|
||||
$ticket->store();
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Comment extends DataStore {
|
||||
const TABLE = 'comments';
|
||||
const TABLE = 'comment';
|
||||
|
||||
public static function getProps() {
|
||||
return array(
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
use RedBeanPHP\Facade as RedBean;
|
||||
|
||||
class Ticket extends DataStore {
|
||||
const TABLE = 'tickets';
|
||||
const TABLE = 'ticket';
|
||||
|
||||
public static function getProps() {
|
||||
return array(
|
||||
'ticketId',
|
||||
'ticketNumber',
|
||||
'title',
|
||||
'content',
|
||||
'language',
|
||||
|
@ -16,15 +17,19 @@ class Ticket extends DataStore {
|
|||
'closed',
|
||||
'author',
|
||||
'owner',
|
||||
'ownComments'
|
||||
'ownCommentList'
|
||||
);
|
||||
}
|
||||
|
||||
public static function getTicket($value, $property = 'id') {
|
||||
return parent::getDataStore($value, $property);
|
||||
}
|
||||
|
||||
protected function getDefaultProps() {
|
||||
|
||||
public function getDefaultProps() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function addComment(Comment $comment) {
|
||||
$this->getBeanInstance()->ownCommentList[] = $comment->getBeanInstance();
|
||||
}
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
use RedBeanPHP\Facade as RedBean;
|
||||
|
||||
class User extends DataStore {
|
||||
const TABLE = 'users';
|
||||
const TABLE = 'user';
|
||||
|
||||
public static function authenticate($userEmail, $userPassword) {
|
||||
$user = User::getUser($userEmail, 'email');
|
||||
|
@ -15,18 +16,16 @@ class User extends DataStore {
|
|||
'password',
|
||||
'name',
|
||||
'verificationToken',
|
||||
'ownTickets'
|
||||
'ownTicketList'
|
||||
);
|
||||
}
|
||||
|
||||
public function getDefaultProps() {
|
||||
return array(
|
||||
'ownTickets' => []
|
||||
);
|
||||
return array();
|
||||
}
|
||||
|
||||
public function addTicket($ticket) {
|
||||
$this->ownTickets[] = $ticket;
|
||||
$this->ownTicketList[] = $ticket;
|
||||
}
|
||||
|
||||
public static function getUser($value, $property = 'id') {
|
||||
|
|
|
@ -50,7 +50,7 @@ describe '/user/login' do
|
|||
})
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
ticket = $database.getRow('tickets','Winter is coming','title')
|
||||
ticket = $database.getRow('ticket','Winter is coming','title')
|
||||
(ticket['content']).should.equal('The north remembers')
|
||||
end
|
||||
end
|
|
@ -5,7 +5,7 @@ describe '/user/signup' do
|
|||
'password' => 'custom'
|
||||
})
|
||||
|
||||
userRow = $database.getRow('users', response['data']['userId'])
|
||||
userRow = $database.getRow('user', response['data']['userId'])
|
||||
|
||||
(userRow['email']).should.equal('steve@jobs.com')
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue