AttachmentCollection.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. declare(strict_types = 1);
  3. namespace Plugin\AttachmentCollections\Entity;
  4. use App\Core\Entity;
  5. use function mb_substr;
  6. class AttachmentCollection extends Entity
  7. {
  8. // These tags are meant to be literally included and will be populated with the appropriate fields, setters and getters by `bin/generate_entity_fields`
  9. // {{{ Autocode
  10. // @codeCoverageIgnoreStart
  11. private int $id;
  12. private string $name;
  13. private int $actor_id;
  14. public function setId(int $id): self
  15. {
  16. $this->id = $id;
  17. return $this;
  18. }
  19. public function getId(): int
  20. {
  21. return $this->id;
  22. }
  23. public function setName(string $name): self
  24. {
  25. $this->name = mb_substr($name, 0, 255);
  26. return $this;
  27. }
  28. public function getName(): string
  29. {
  30. return $this->name;
  31. }
  32. public function setActorId(int $actor_id): self
  33. {
  34. $this->actor_id = $actor_id;
  35. return $this;
  36. }
  37. public function getActorId(): int
  38. {
  39. return $this->actor_id;
  40. }
  41. // @codeCoverageIgnoreEnd
  42. // }}} Autocode
  43. public static function schemaDef()
  44. {
  45. return [
  46. 'name' => 'collection',
  47. 'fields' => [
  48. 'id' => ['type' => 'serial', 'not null' => true, 'description' => 'unique identifier'],
  49. 'name' => ['type' => 'varchar', 'length' => 255, 'not null' => true, 'description' => 'collection\'s name'],
  50. 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to many', 'not null' => true, 'description' => 'foreign key to actor table'],
  51. ],
  52. 'primary key' => ['id'],
  53. ];
  54. }
  55. }