File tree Expand file tree Collapse file tree 2 files changed +134
-0
lines changed
Expand file tree Collapse file tree 2 files changed +134
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace AppBundle \Entity ;
4+
5+ use Doctrine \Common \Collections \ArrayCollection ;
6+ use Doctrine \Common \Collections \Collection ;
7+ use Doctrine \ORM \Mapping as ORM ;
8+ use ApiPlatform \Core \Annotation \ApiResource ;
9+
10+ /**
11+ * @ApiResource
12+ *
13+ * @ORM\Entity
14+ */
15+ class Book
16+ {
17+ /**
18+ * @ORM\Id
19+ * @ORM\Column(type="string")
20+ * @ORM\GeneratedValue(strategy="UUID")
21+ *
22+ * @var string
23+ */
24+ private $ uuid ;
25+
26+ /**
27+ * @ORM\Column(type="string")
28+ *
29+ * @var string
30+ */
31+ private $ name ;
32+
33+ /**
34+ * @ORM\OneToMany(targetEntity="Review", mappedBy="book")
35+ *
36+ * @var Review[]
37+ */
38+ private $ reviews ;
39+
40+ /**
41+ * Book constructor.
42+ *
43+ */
44+ public function __construct ()
45+ {
46+ $ this ->reviews = new ArrayCollection ();
47+ }
48+
49+ /**
50+ * @return string
51+ */
52+ public function getUuid (): string
53+ {
54+ return $ this ->uuid ;
55+ }
56+
57+ /**
58+ * @param string $uuid
59+ */
60+ public function setUuid (string $ uuid )
61+ {
62+ $ this ->uuid = $ uuid ;
63+ }
64+
65+ /**
66+ * @return string
67+ */
68+ public function getName (): string
69+ {
70+ return $ this ->name ;
71+ }
72+
73+ /**
74+ * @param string $name
75+ */
76+ public function setName (string $ name )
77+ {
78+ $ this ->name = $ name ;
79+ }
80+
81+ /**
82+ * @return Collection|Review[]
83+ */
84+ public function getReviews (): Collection
85+ {
86+ return $ this ->reviews ;
87+ }
88+
89+ /**
90+ * @param Review[] $reviews
91+ */
92+ public function setReviews (array $ reviews )
93+ {
94+ $ this ->reviews = $ reviews ;
95+ }
96+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace AppBundle \Entity ;
4+
5+ use Doctrine \ORM \Mapping as ORM ;
6+ use ApiPlatform \Core \Annotation \ApiResource ;
7+
8+ /**
9+ * @ORM\Entity
10+ *
11+ * @ApiResource
12+ */
13+ class Review
14+ {
15+ /**
16+ * @ORM\Id
17+ * @ORM\Column(type="string")
18+ * @ORM\GeneratedValue(strategy="UUID")
19+ *
20+ * @var string
21+ */
22+ private $ uuid ;
23+
24+ /**
25+ * @ORM\Column(type="text")
26+ *
27+ * @var string
28+ */
29+ private $ contents ;
30+
31+ /**
32+ * @ORM\ManyToOne(targetEntity="Book", inversedBy="reviews")
33+ * @ORM\JoinColumn(name="book_uuid", referencedColumnName="uuid")
34+ *
35+ * @var Book
36+ */
37+ private $ book ;
38+ }
You can’t perform that action at this time.
0 commit comments