Bonjour à tous,
J'aurais besoin de votre aide pour trouver ce qui ne va pas dans mon mapping, j'ai beau regarder je vois rien qui cloche au niveau de l'orthographe, j'ai effectué à chaque fois une migration puis un schema:validate mais le problème ressort à chaque fois et paralyse la consultation de la bdd (images)...
Merci d'avance
entité images.php :[FAIL] The entity-class App\Entity\Images mapping is invalid:
* The mappings App\Entity\Images#plats and App\Entity\Plats#images are inconsistent with each other.
PS E:\OD Pro\Studi\Evaluation_Restaurant> php bin/console doctrine:schema:validate
Mapping
[FAIL] The entity-class App\Entity\Plats mapping is invalid:
* The association App\Entity\Plats#ingredients refers to the inverse side field App\Entity\Ingredients#Plats which does not exist.
Database
[ERROR] The database schema is not in sync with the current mapping file.
entité Plats :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112 <?php namespace App\Entity; use App\Repository\ImagesRepository; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: ImagesRepository::class)] class Images { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $name = null; #[ORM\ManyToOne(inversedBy: 'images')] #[ORM\JoinColumn(nullable: false)] private ?Plats $plats = null; #[ORM\Column(length: 255, nullable: true)] private ?string $titre = null; #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $description = null; #[ORM\Column(nullable: true)] private ?int $taille = null; #[ORM\ManyToOne(inversedBy: 'images')] private ?CMSAccueil $cmsAccueil = null; public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getPlats(): ?Plats { return $this->plats; } public function setPlats(?Plats $plats): self { $this->plats = $plats; return $this; } public function getTitre(): ?string { return $this->titre; } public function setTitre(?string $titre): self { $this->titre = $titre; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } public function getTaille(): ?int { return $this->taille; } public function setTaille(?int $taille): self { $this->taille = $taille; return $this; } public function getCmsAccueil(): ?CMSAccueil { return $this->cmsAccueil; } public function setCmsAccueil(?CMSAccueil $cmsAccueil): self { $this->cmsAccueil = $cmsAccueil; return $this; } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155 <?php namespace App\Entity; use App\Entity\Trait\CreatedAtTrait; use App\Entity\Trait\SlugTrait; use App\Repository\PlatsRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: PlatsRepository::class)] class Plats { use CreatedAtTrait; use SlugTrait; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $name = null; #[ORM\Column(type: Types::TEXT)] private ?string $description = null; #[ORM\Column(options:['default'=>0])] private ?int $price = null; #[ORM\ManyToOne(inversedBy: 'Plats')] #[ORM\JoinColumn(nullable: false)] private ?CategoriesPlats $categories = null; #[ORM\OneToMany(mappedBy: 'plats', targetEntity: Images::class, cascade: ['persist'], orphanRemoval: true)] private Collection $images; #[ORM\ManyToMany(targetEntity: Ingredients::class,orphanRemoval: true, inversedBy: 'Plats')] private Collection $ingredients; public function __construct() { $this->images = new ArrayCollection(); $this->Created_At = new \DateTimeImmutable(); $this->ingredients = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(string $description): self { $this->description = $description; return $this; } public function getPrice(): ?int { return $this->price; } public function setPrice(int $price): self { $this->price = $price; return $this; } public function getCategories(): ?CategoriesPlats { return $this->categories; } public function setCategories(?CategoriesPlats $categories): self { $this->categories = $categories; return $this; } /** * @return Collection<int, Images> */ public function getImages(): Collection { return $this->images; } public function addImage(Images $image): self { if (!$this->images->contains($image)) { $this->images->add($image); $image->setPlats($this); } return $this; } public function removeImage(Images $image): self { if ($this->images->removeElement($image)) { // set the owning side to null (unless already changed) if ($image->getPlats() === $this) { $image->setPlats(null); } } return $this; } /** * @return Collection<int, Ingredients> */ public function getIngredients(): Collection { return $this->ingredients; } public function addIngredient(Ingredients $ingredient): self { if (!$this->ingredients->contains($ingredient)) { $this->ingredients->add($ingredient); } return $this; } public function removeIngredient(Ingredients $ingredient): self { $this->ingredients->removeElement($ingredient); return $this; } }
Partager