diff options
author | Daniel Weipert <code@drogueronin.de> | 2022-01-16 12:22:04 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2022-01-16 12:22:04 +0100 |
commit | 8d58c7de92c75e826a8399ec7914b463f8916dcd (patch) | |
tree | 9663d390c7474c3a883438c16d7e0015c576cf04 /src/Model/Category.php | |
parent | 4cacc94240944ff316104bfd1b5e8e00fad14517 (diff) |
Add categories for cards and relate them to meta
Diffstat (limited to 'src/Model/Category.php')
-rw-r--r-- | src/Model/Category.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/Model/Category.php b/src/Model/Category.php new file mode 100644 index 0000000..84d12a3 --- /dev/null +++ b/src/Model/Category.php @@ -0,0 +1,61 @@ +<?php + +namespace Elements\Model; + +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\Table; +use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\GeneratedValue; +use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\ManyToMany; +use Doctrine\ORM\Mapping\ManyToOne; +use Doctrine\ORM\PersistentCollection; + +#[Entity] +#[Table(name: 'categories')] +/** + * @Entity + * @Table(name="categories") + */ +class Category +{ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + public int $id; + + #[Column(type: 'string')] + /** + * @Column(type="string") + */ + public string $name; + + #[ManyToMany(targetEntity: Card::class, mappedBy: 'categories')] + /** + * @ManyToMany(targetEntity="Card", mappedBy="categories", cascade={"persist"}) + */ + public Collection|ArrayCollection|PersistentCollection $cards; + + #[ManyToMany(targetEntity: CardMeta::class, mappedBy: 'categories')] + /** + * @ManyToMany(targetEntity="CardMeta", mappedBy="categories", cascade={"persist"}) + */ + public Collection|ArrayCollection|PersistentCollection $meta; + + /** + * Category constructor. + */ + public function __construct(string $name) + { + $this->name = $name; + $this->cards = new ArrayCollection(); + $this->meta = new ArrayCollection(); + } +} + |