|
14 | 14 |
|
15 | 15 | use Brille24\SyliusCustomerOptionsPlugin\Entity\OrderItemOptionInterface; |
16 | 16 | use Brille24\SyliusCustomerOptionsPlugin\Enumerations\CustomerOptionTypeEnum; |
| 17 | +use Brille24\SyliusCustomerOptionsPlugin\Repository\CustomerOptionRepository; |
17 | 18 | use Doctrine\Common\Collections\ArrayCollection; |
18 | 19 | use Doctrine\Common\Collections\Collection; |
| 20 | +use Doctrine\DBAL\Types\JsonType; |
| 21 | +use Doctrine\ORM\Mapping as ORM; |
19 | 22 | use Sylius\Component\Resource\Model\TranslatableTrait; |
20 | 23 | use Sylius\Component\Resource\Model\TranslationInterface; |
21 | 24 |
|
| 25 | +#[ORM\Entity(repositoryClass: CustomerOptionRepository::class)] |
| 26 | +#[ORM\Table(name: 'brille24_customer_option')] |
22 | 27 | class CustomerOption implements CustomerOptionInterface |
23 | 28 | { |
24 | 29 | use TranslatableTrait { |
25 | 30 | __construct as protected initializeTranslationsCollection; |
26 | 31 | getTranslation as private doGetTranslation; |
27 | 32 | } |
28 | 33 |
|
| 34 | + #[ORM\Id] |
| 35 | + #[ORM\GeneratedValue(strategy: 'AUTO')] |
| 36 | + #[ORM\Column(type: 'integer')] |
29 | 37 | protected ?int $id = null; |
30 | 38 |
|
| 39 | + #[ORM\Column(type: 'string', nullable: false)] |
31 | 40 | protected string $type = CustomerOptionTypeEnum::SELECT; |
32 | 41 |
|
| 42 | + #[ORM\Column(type: 'string', unique: true, nullable: false)] |
33 | 43 | protected ?string $code = ''; |
34 | 44 |
|
| 45 | + #[ORM\Column(type: 'boolean')] |
35 | 46 | protected bool $required = false; |
36 | 47 |
|
37 | 48 | /** @var Collection|CustomerOptionValueInterface[] */ |
| 49 | + #[ORM\OneToMany(targetEntity: CustomerOptionValueInterface::class, mappedBy: 'customerOption', orphanRemoval: true, cascade: ['persist', 'remove'])] |
| 50 | + #[ORM\OrderBy(['id' => 'ASC'])] |
38 | 51 | protected Collection $values; |
39 | 52 |
|
| 53 | + #[ORM\Column(type: 'json')] |
40 | 54 | protected array $configuration = []; |
41 | 55 |
|
| 56 | + /** @var Collection|CustomerOptionAssociationInterface[] */ |
| 57 | + #[ORM\OneToMany(targetEntity: CustomerOptionAssociationInterface::class, mappedBy: 'option', orphanRemoval: true, cascade: ['persist'])] |
| 58 | + #[ORM\OrderBy(['position' => 'ASC'])] |
42 | 59 | protected Collection $groupAssociations; |
43 | 60 |
|
44 | 61 | /** @var Collection|OrderItemOptionInterface[] */ |
| 62 | + #[ORM\OneToMany(targetEntity: OrderItemOptionInterface::class, mappedBy: 'customerOption')] |
45 | 63 | protected Collection $orders; |
46 | 64 |
|
47 | 65 | public function __construct() |
|
0 commit comments