2020-06-07 19:04:43 +03:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
namespace openvk\Web\Models\Repositories;
|
2022-05-08 13:06:26 +03:00
|
|
|
# use openvk\Web\Models\Entities\Ticket;
|
|
|
|
# use openvk\Web\Models\Entities\User;
|
|
|
|
# use openvk\Web\Models\Repositories\Users;
|
2020-06-07 19:04:43 +03:00
|
|
|
use openvk\Web\Models\Entities\TicketComment;
|
|
|
|
use Chandler\Database\DatabaseConnection;
|
|
|
|
|
|
|
|
class TicketComments
|
|
|
|
{
|
|
|
|
private $context;
|
|
|
|
private $comments;
|
|
|
|
|
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
$this->context = DatabaseConnection::i()->getContext();
|
|
|
|
$this->comments = $this->context->table("tickets_comments");
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCommentsById(int $ticket_id): \Traversable
|
|
|
|
{
|
2022-01-28 16:34:13 +03:00
|
|
|
foreach($this->comments->where(['ticket_id' => $ticket_id, 'deleted' => 0]) as $comment) yield new TicketComment($comment);
|
2020-06-07 19:04:43 +03:00
|
|
|
}
|
|
|
|
|
2022-05-08 13:06:26 +03:00
|
|
|
# private function toTicket(?ActiveRow $ar): ?Ticket
|
|
|
|
# {
|
|
|
|
# return is_null($ar) ? NULL : new Ticket($ar);
|
|
|
|
# }
|
2020-06-07 19:04:43 +03:00
|
|
|
|
2022-05-08 13:06:26 +03:00
|
|
|
# function getTicketsByuId(int $user_id): \Traversable
|
|
|
|
# {
|
|
|
|
# foreach($this->tickets->where(['user_id' => $user_id, 'deleted' => 0]) as $ticket) yield new Ticket($ticket);
|
|
|
|
# }
|
2020-06-07 19:04:43 +03:00
|
|
|
|
2022-05-08 13:06:26 +03:00
|
|
|
# function getRequestById(int $req_id): ?Ticket
|
|
|
|
# {
|
|
|
|
# $requests = $this->tickets->where(['id' => $req_id])->fetch();
|
|
|
|
# if(!is_null($requests))
|
2020-06-07 19:04:43 +03:00
|
|
|
|
2022-05-08 13:06:26 +03:00
|
|
|
# return new Req($requests);
|
|
|
|
# else
|
|
|
|
# return null;
|
2020-06-07 19:04:43 +03:00
|
|
|
|
2022-05-08 13:06:26 +03:00
|
|
|
# }
|
2020-06-07 19:04:43 +03:00
|
|
|
|
2022-05-08 13:06:26 +03:00
|
|
|
# function get(int $id): ?Ticket
|
|
|
|
# {
|
|
|
|
# return $this->toTicket($this->tickets->get($id));
|
|
|
|
# }
|
2021-12-15 01:56:23 +03:00
|
|
|
|
|
|
|
function get(int $id): ?TicketComment
|
|
|
|
{
|
|
|
|
$comment = $this->comments->get($id);;
|
|
|
|
if (!is_null($comment))
|
|
|
|
return new TicketComment($comment);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
2020-06-07 19:04:43 +03:00
|
|
|
|
|
|
|
use \Nette\SmartObject;
|
|
|
|
}
|