Jacek Kowalski
4 hours ago 6b9278a5d57091fce636dbb640b380cfb990db6c
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
<?php
declare(strict_types=1);
 
namespace App\Entity;
 
use App\Enum\LabelType;
use App\Repository\LabelRepository;
use Doctrine\ORM\Mapping as ORM;
 
#[ORM\Entity(repositoryClass: LabelRepository::class)]
#[ORM\UniqueConstraint(name: 'label_book_type_label', columns: ['book_id', 'type', 'label'])]
#[ORM\Index(name: 'label_label', columns: ['label'])]
class Label extends AbstractLabel {
    #[ORM\ManyToOne(targetEntity: Book::class, inversedBy: 'labels')]
    #[ORM\JoinColumn(nullable: false)]
    private Book $book;
 
    public function __construct(Book $book, string $label, LabelType $type = LabelType::TEXT) {
        parent::__construct($label, $type);
        $this->book = $book;
    }
 
    public function getBook(): Book {
        return $this->book;
    }
}