summaryrefslogtreecommitdiff
path: root/src/Model/CardMeta.php
blob: a77e339c4f48a5b7c7c1aed266802f33f58916fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?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\Index;
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\PersistentCollection;

#[Entity]
#[Table(name: 'card_meta')]
#[Index(columns: ['key'])]
/**
 * @Entity
 * @Table(name="card_meta", indexes={@Index(columns={"key"})})
 */
class CardMeta
{
  #[Id]
  #[Column(type: 'integer')]
  #[GeneratedValue]
  /**
   * @Id
   * @Column(type="integer")
   * @GeneratedValue
   */
  public int $id;

  #[Column(type: 'string')]
  /**
   * @Column(type="string")
   */
  public string $key;

  #[Column(type: 'string')]
  /**
   * @Column(type="string")
   */
  public string $value;

  #[ManyToOne(targetEntity: Card::class, inversedBy: 'meta')]
  /**
   * @ManyToOne(targetEntity="Card", inversedBy="meta", cascade={"persist"})
   */
  public Card $card;

  #[ManyToMany(targetEntity: Category::class, inversedBy: 'meta')]
  /**
   * @ManyToMany(targetEntity="Category", inversedBy="meta", cascade={"persist"})
   */
  public Collection|ArrayCollection|PersistentCollection $categories;

  /**
   * CardMeta constructor.
   */
  public function __construct(string $key, string $value)
  {
    $this->key = $key;
    $this->value = $value;
    $this->categories = new ArrayCollection();
  }
}