123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <?php
- namespace Plugin\Poll\Entity;
- use App\Core\DB\DB;
- use App\Core\Entity;
- use DateTimeInterface;
- class PollResponse extends Entity
- {
-
-
- private int $id;
- private ?string $uri;
- private int $poll_id;
- private ?int $gsactor_id;
- private ?int $selection;
- private \DateTimeInterface $created;
- private \DateTimeInterface $modified;
- public function setId(int $id): self
- {
- $this->id = $id;
- return $this;
- }
- public function getId(): int
- {
- return $this->id;
- }
- public function setUri(?string $uri): self
- {
- $this->uri = $uri;
- return $this;
- }
- public function getUri(): ?string
- {
- return $this->uri;
- }
- public function setPollId(int $poll_id): self
- {
- $this->poll_id = $poll_id;
- return $this;
- }
- public function getPollId(): int
- {
- return $this->poll_id;
- }
- public function setGSActorId(?int $gsactor_id): self
- {
- $this->gsactor_id = $gsactor_id;
- return $this;
- }
- public function getGSActorId(): ?int
- {
- return $this->gsactor_id;
- }
- public function setSelection(?int $selection): self
- {
- $this->selection = $selection;
- return $this;
- }
- public function getSelection(): ?int
- {
- return $this->selection;
- }
- public function setCreated(DateTimeInterface $created): self
- {
- $this->created = $created;
- return $this;
- }
- public function getCreated(): DateTimeInterface
- {
- return $this->created;
- }
- public function setModified(DateTimeInterface $modified): self
- {
- $this->modified = $modified;
- return $this;
- }
- public function getModified(): DateTimeInterface
- {
- return $this->modified;
- }
-
-
-
- public static function schemaDef()
- {
- return [
- 'name' => 'pollresponse',
- 'description' => 'Record of responses to polls',
- 'fields' => [
- 'id' => ['type' => 'serial', 'not null' => true],
-
- 'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'UUID to the response notice'],
- 'poll_id' => ['type' => 'int', 'length' => 36, 'not null' => true, 'description' => 'UUID of poll being responded to'],
- 'gsactor_id' => ['type' => 'int'],
- 'selection' => ['type' => 'int'],
- 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
- 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
- ],
- 'primary key' => ['id'],
- 'unique keys' => [
-
-
- ],
- 'foreign keys' => [
- 'foreign_poll' => ['poll', ['poll_id' => 'id']],
- ],
- 'indexes' => [
- 'poll_response_gsactor_id_poll_id_index' => ['gsactor_id', 'poll_id'],
- ],
- ];
- }
-
- public static function exits(int $pollId, int $gsactorId): bool
- {
- $res = DB::dql('select pr from App\Entity\PollResponse pr
- where pr.poll_id = :pollId and pr.gsactor_id = :gsactorId',
- ['pollId' => $pollId, 'gsactorId' => $gsactorId]);
- return count($res) != 0;
- }
- }
|