Bonjour à tous,

Symfony m'indique :

An exception has been thrown during the rendering of a template ("No mapping found for field 'option_vehicule' on class 'App\Entity\ListeOptionsVehicule'.").
Je suppose qu'il manque un mappedBy quelque part mais étant débutant je ne sais pas comment l'implémenter...

Merci d'avance pour votre aide

listeoptionsvehicule.php

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
<?php
 
namespace App\Entity;
 
use App\Repository\ListeOptionsVehiculeRepository;
use Doctrine\ORM\Mapping as ORM;
 
#[ORM\Entity(repositoryClass: ListeOptionsVehiculeRepository::class)]
class ListeOptionsVehicule
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;
 
    #[ORM\ManyToOne(inversedBy: 'listeOptionsVehicule')]
    #[ORM\JoinColumn(nullable: false)]
    private ?Vehicules $vehicule = null;
 
    #[ORM\ManyToOne(inversedBy: 'listeOptionsVehicule', cascade: ['persist', 'remove'])]
    #[ORM\JoinColumn(nullable: false)]
    private ?OptionsVehicules $option_vehicule = null;
 
    public function getId(): ?int
    {
        return $this->id;
    }
 
    public function getVehicule(): ?Vehicules
    {
        return $this->vehicule;
    }
 
    public function setVehicule(?Vehicules $vehicule): self
    {
        $this->vehicule = $vehicule;
 
        return $this;
    }
 
    public function getOptionVehicule(): ?OptionsVehicules
    {
        return $this->option_vehicule;
    }
 
    public function setOptionVehicule(?OptionsVehicules $option_vehicule): self
    {
        $this->option_vehicule = $option_vehicule;
 
        return $this;
    }
}
vehicules.php

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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
<?php
 
namespace App\Entity;
 
use App\Entity\Trait\CreatedAtTrait;
use App\Entity\Trait\SlugTrait;
use App\Repository\VehiculesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
 
#[ORM\Entity(repositoryClass: VehiculesRepository::class)]
class Vehicules
{
    use CreatedAtTrait;
    use SlugTrait;
 
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;
 
    #[ORM\Column(length: 100)]
    private ?string $modele = null;
 
    #[ORM\Column(length: 100)]
    private ?string $motorisation = null;
 
    #[ORM\Column(nullable: true)]
    private ?int $cylindree = null;
 
    #[ORM\Column(nullable: true)]
    private ?int $nb_portes = null;
 
    #[ORM\Column]
    private ?int $prix_vente = null;
 
    #[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
    private ?\DateTimeInterface $date_mise_en_circulation = null;
 
    #[ORM\Column(nullable: true)]
    private ?int $nb_places = null;
 
    #[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
    private ?\DateTimeInterface $date_mise_en_vente = null;
 
    #[ORM\OneToMany(mappedBy: 'id_vehicule', targetEntity: Photos::class, orphanRemoval: true, cascade: ['persist'])]
    private Collection $photos;
 
    #[ORM\Column(length: 100, nullable: true)]
    private ?string $boite = null;
 
    #[ORM\Column(length: 255, nullable: true)]
    private ?string $num_chassis = null;
 
    #[ORM\Column(length: 100, nullable: true)]
    private ?string $localisation = null;
 
    #[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
    private ?\DateTimeInterface $date_vente = null;
 
    #[ORM\Column(length: 100, nullable: true)]
    private ?string $critere_pollution = null;
 
    #[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
    private ?\DateTimeInterface $date_controle_technique = null;
 
    #[ORM\Column(type: Types::TEXT, nullable: true)]
    private ?string $remarques = null;
 
    #[ORM\Column(nullable: true)]
    private ?int $kilometrage = null;
 
    #[ORM\Column(nullable: true)]
    private ?int $nb_proprietaires = null;
 
    #[ORM\Column(nullable: true)]
    private ?float $chevaux_fiscaux = null;
 
    #[ORM\Column(nullable: true)]
    private ?float $chevaux_din = null;
 
    #[ORM\ManyToOne(inversedBy: 'vehicules')]
    #[ORM\JoinColumn(nullable: false)]
    private ?Marques $marque = null;
 
    #[ORM\Column(length: 100, nullable: true)]
    private ?string $reference_interne = null;
 
    #[ORM\Column(length: 15, nullable: true)]
    private ?string $plaque_immatriculation = null;
 
    #[ORM\ManyToOne(inversedBy: 'vehicules')]
    private ?Clients $proprietaire = null;
 
    #[ORM\OneToMany(mappedBy: 'vehicule', targetEntity: ListeOptionsVehicule::class, orphanRemoval: true)]
    private Collection $listeOptionsVehicule;
 
    #[ORM\Column(nullable: true)]
    private ?bool $publication_annonce = null;
 
    #[ORM\ManyToOne(inversedBy: 'vehicules')]
    #[ORM\JoinColumn(nullable: false)]
    private ?Couleurs $couleur = null;
 
    #[ORM\ManyToOne(inversedBy: 'vehicules')]
    #[ORM\JoinColumn(nullable: false)]
    private ?TypesVehicules $type_vehicule = null;
 
    #[ORM\ManyToMany(targetEntity: Users::class, inversedBy: 'favoris')]
    private Collection $favoris;
 
    public function __construct()
    {
        $this->photos = new ArrayCollection();
        $this->listeOptionsVehicule = new ArrayCollection();     
        $this->created_at = new \DateTimeImmutable();
        $this->favoris = new ArrayCollection();                    
    }
 
    public function getId(): ?int
    {
        return $this->id;
    }
 
    public function getModele(): ?string
    {
        return $this->modele;
    }
 
    public function setModele(string $modele): self
    {
        $this->modele = $modele;
 
        return $this;
    }
 
    public function getMotorisation(): ?string
    {
        return $this->motorisation;
    }
 
    public function setMotorisation(string $motorisation): self
    {
        $this->motorisation = $motorisation;
 
        return $this;
    }
 
    public function getCylindree(): ?int
    {
        return $this->cylindree;
    }
 
    public function setCylindree(?int $cylindree): self
    {
        $this->cylindree = $cylindree;
 
        return $this;
    }
 
    public function getNbPortes(): ?int
    {
        return $this->nb_portes;
    }
 
    public function setNbPortes(?int $nb_portes): self
    {
        $this->nb_portes = $nb_portes;
 
        return $this;
    }
 
    public function getPrixVente(): ?int
    {
        return $this->prix_vente;
    }
 
    public function setPrixVente(int $prix_vente): self
    {
        $this->prix_vente = $prix_vente;
 
        return $this;
    }
 
    public function getDateMiseEnCirculation(): ?\DateTimeInterface
    {
        return $this->date_mise_en_circulation;
    }
 
    public function setDateMiseEnCirculation(?\DateTimeInterface $date_mise_en_circulation): self
    {
        $this->date_mise_en_circulation = $date_mise_en_circulation;
 
        return $this;
    }
 
    public function getNbPlaces(): ?int
    {
        return $this->nb_places;
    }
 
    public function setNbPlaces(?int $nb_places): self
    {
        $this->nb_places = $nb_places;
 
        return $this;
    }
 
    public function getDateMiseEnVente(): ?\DateTimeInterface
    {
        return $this->date_mise_en_vente;
    }
 
    public function setDateMiseEnVente(?\DateTimeInterface $date_mise_en_vente): self
    {
        $this->date_mise_en_vente = $date_mise_en_vente;
 
        return $this;
    }
 
    /**
     * @return Collection<int, Photos>
     */
    public function getPhotos(): Collection
    {
        return $this->photos;
    }
 
    public function addPhoto(Photos $photo): self
    {
        if (!$this->photos->contains($photo)) {
            $this->photos->add($photo);
            $photo->setIdVehicule($this);
        }
 
        return $this;
    }
 
    public function removePhoto(Photos $photo): self
    {
        if ($this->photos->removeElement($photo)) {
            // set the owning side to null (unless already changed)
            if ($photo->getIdVehicule() === $this) {
                $photo->setIdVehicule(null);
            }
        }
 
        return $this;
    }
    public function getBoite(): ?string
    {
        return $this->boite;
    }
 
    public function setBoite(?string $boite): self
    {
        $this->boite = $boite;
 
        return $this;
    }
 
    public function getNumChassis(): ?string
    {
        return $this->num_chassis;
    }
 
    public function setNumChassis(?string $num_chassis): self
    {
        $this->num_chassis = $num_chassis;
 
        return $this;
    }
 
    public function getLocalisation(): ?string
    {
        return $this->localisation;
    }
 
    public function setLocalisation(?string $localisation): self
    {
        $this->localisation = $localisation;
 
        return $this;
    }
 
    public function getDateVente(): ?\DateTimeInterface
    {
        return $this->date_vente;
    }
 
    public function setDateVente(?\DateTimeInterface $date_vente): self
    {
        $this->date_vente = $date_vente;
 
        return $this;
    }
 
    public function getCriterePollution(): ?string
    {
        return $this->critere_pollution;
    }
 
    public function setCriterePollution(?string $critere_pollution): self
    {
        $this->critere_pollution = $critere_pollution;
 
        return $this;
    }
 
    public function getDateControleTechnique(): ?\DateTimeInterface
    {
        return $this->date_controle_technique;
    }
 
    public function setDateControleTechnique(?\DateTimeInterface $date_controle_technique): self
    {
        $this->date_controle_technique = $date_controle_technique;
 
        return $this;
    }
 
    public function getRemarques(): ?string
    {
        return $this->remarques;
    }
 
    public function setRemarques(?string $remarques): self
    {
        $this->remarques = $remarques;
 
        return $this;
    }
 
    public function getKilometrage(): ?int
    {
        return $this->kilometrage;
    }
 
    public function setKilometrage(?int $kilometrage): self
    {
        $this->kilometrage = $kilometrage;
 
        return $this;
    }
 
    public function getNbProprietaires(): ?int
    {
        return $this->nb_proprietaires;
    }
 
    public function setNbProprietaires(?int $nb_proprietaires): self
    {
        $this->nb_proprietaires = $nb_proprietaires;
 
        return $this;
    }
 
    public function getChevauxFiscaux(): ?float
    {
        return $this->chevaux_fiscaux;
    }
 
    public function setChevauxFiscaux(?float $chevaux_fiscaux): self
    {
        $this->chevaux_fiscaux = $chevaux_fiscaux;
 
        return $this;
    }
 
    public function getChevauxDin(): ?float
    {
        return $this->chevaux_din;
    }
 
    public function setChevauxDin(?float $chevaux_din): self
    {
        $this->chevaux_din = $chevaux_din;
 
        return $this;
    }
 
    public function getMarque(): ?Marques
    {
        return $this->marque;
    }
 
    public function setMarque(?Marques $marque): self
    {
        $this->marque = $marque;
 
        return $this;
    }
 
 
    public function __toString(): string
    {
        return $this->marque;
    }
 
 
    public function getReferenceInterne(): ?string
    {
        return $this->reference_interne;
    }
 
    public function setReferenceInterne(?string $reference_interne): self
    {
        $this->reference_interne = $reference_interne;
 
        return $this;
    }
 
    public function getPlaqueImmatriculation(): ?string
    {
        return $this->plaque_immatriculation;
    }
 
    public function setPlaqueImmatriculation(?string $plaque_immatriculation): self
    {
        $this->plaque_immatriculation = $plaque_immatriculation;
 
        return $this;
    }
 
    public function getProprietaire(): ?Clients
    {
        return $this->proprietaire;
    }
 
    public function setProprietaire(?Clients $proprietaire): self
    {
        $this->proprietaire = $proprietaire;
 
        return $this;
    }
 
    /**
     * @return Collection<int, ListeOptionsVehicule>
     */
    public function getListeOptionsVehicule(): Collection
    {
        return $this->listeOptionsVehicule;
    }
 
    public function addListeOptionsVehicule(ListeOptionsVehicule $listeOptionsVehicule): self
    {
        if (!$this->listeOptionsVehicule->contains($listeOptionsVehicule)) {
            $this->listeOptionsVehicule->add($listeOptionsVehicule);
            $listeOptionsVehicule->setVehicule($this);
        }
 
        return $this;
    }
 
    public function removeListeOptionsVehicule(ListeOptionsVehicule $listeOptionsVehicule): self
    {
        if ($this->listeOptionsVehicule->removeElement($listeOptionsVehicule)) {
            // set the owning side to null (unless already changed)
            if ($listeOptionsVehicule->getVehicule() === $this) {
                $listeOptionsVehicule->setVehicule(null);
            }
        }
 
        return $this;
    }
 
    public function isPublicationAnnonce(): ?bool
    {
        return $this->publication_annonce;
    }
 
    public function setPublicationAnnonce(?bool $publication_annonce): self
    {
        $this->publication_annonce = $publication_annonce;
 
        return $this;
    }
 
    public function getCouleur(): ?Couleurs
    {
        return $this->couleur;
    }
 
    public function setCouleur(?Couleurs $couleur): self
    {
        $this->couleur = $couleur;
 
        return $this;
    }
 
    public function getTypeVehicule(): ?TypesVehicules
    {
        return $this->type_vehicule;
    }
 
    public function setTypeVehicule(?TypesVehicules $type_vehicule): self
    {
        $this->type_vehicule = $type_vehicule;
 
        return $this;
    }
 
    /**
     * @return Collection<int, Users>
     */
    public function getFavoris(): Collection
    {
        return $this->favoris;
    }
 
    public function addFavori(Users $favori): self
    {
        if (!$this->favoris->contains($favori)) {
            $this->favoris->add($favori);
        }
 
        return $this;
    }
 
    public function removeFavori(Users $favori): self
    {
        $this->favoris->removeElement($favori);
 
        return $this;
    }
}
details.html.twig

Code html : 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
{% extends "base.html.twig" %}
{% block title %}Détails véhicule
{% endblock %}
{% block body %}
	<div class="main">
		<h1 class="titre-principal">Fiche véhicule</h1>
 
		<a class="btn btn-go-back" href="{{path('app_vehicules_liste_vehicules')}}">Revenir à la liste</a>
 
		{{ include('_partials/_galerie-photos.html.twig') }}
 
		{# Fiche de détails véhicule #}
		<table class="table fiche-vehicule">
			<thead>
				<th>
					<a class="btn btn-primary" href="{{path('app_vehicules_modifier_vehicule',{id:vehicule.id})}}">Editer la fiche</a>
				</th>
				<th>
					<a href="#" class="btn btn-danger">Supprimer ce véhicule</a>
				</th>
			</thead>
 
			<tbody>
 
				<tr>
					<td class="table-label">Reference interne</td>
					<td>
						<strong>{{vehicule.referenceinterne}}</strong>
					</td>
				</tr>
 
				<tr>
					<td class="table-label">Marque</td>
 
					<td>
						<strong>{{vehicule.marque}}</strong>
					</td>
				</tr>
				<tr>
					<td class="table-label">Modèle</td>
 
					<td>{{vehicule.modele}}</td>
				</tr>
				<tr>
					<td class="table-label">Kilomètrage</td>
 
					<td>{{vehicule.kilometrage}}</td>
				</tr>
				<tr>
					<td class="table-label">Plaque immatriculation</td>
 
					<td>{{vehicule.plaqueimmatriculation}}</td>
				</tr>
 
				<tr>
					<td class="table-label">Propietaire</td>
 
					<td>
						<a href="#">{{vehicule.proprietaire.nom}}
							{{vehicule.proprietaire.prenom}}</a>
					</td>
 
				</tr>
 
				<tr>
					<td class="table-label">Motorisation</td>
 
					<td>{{vehicule.motorisation}}</td>
				</tr>
				<tr>
					<td class="table-label">Cylindree</td>
 
					<td>{{vehicule.cylindree}}</td>
				</tr>
				<tr>
					<td class="table-label">Nbre portes</td>
 
					<td>{{vehicule.nbportes}}</td>
				</tr>
				<tr>
					<td class="table-label">Prix vente</td>
 
					<td>{{vehicule.prixvente}}</td>
				</tr>
				<tr>
					<td class="table-label">Couleur</td>
 
					<td>{{vehicule.couleur}}</td>
				</tr>
				<tr>
					<td class="table-label">Date mise en circulation</td>
 
					<td>{{vehicule.datemiseencirculation}}</td>
				</tr>
				<tr>
					<td class="table-label">Date mise en vente</td>
 
					<td>{{vehicule.datemiseenvente}}</td>
				</tr>
				<tr></tr>
				<tr>
					<td class="table-label">Date controle technique</td>
 
					<td>{{vehicule.datecontroletechnique}}</td>
				</tr>
				<tr>
					<td class="table-label">Nbre places</td>
 
					<td>{{vehicule.datemiseenvente}}</td>
				</tr>
				<tr>
					<td class="table-label">Type véhicule</td>
 
					<td>{{vehicule.typevehicule}}</td>
				</tr>
				<tr>
					<td class="table-label">Type boîte</td>
 
					<td>{{vehicule.boite}}</td>
				</tr>
				<tr>
					<td class="table-label">N° chassis</td>
 
					<td>{{vehicule.numchassis}}</td>
				</tr>
				<tr>
					<td class="table-label">Nbr propriétaires</td>
 
					<td>{{vehicule.nbproprietaires}}</td>
				</tr>
				<tr>
					<td class="table-label">Chevaux / puissance</td>
 
					<td>{{vehicule.chevauxfiscaux}}cv/({{vehicule.chevauxdin}}
						din.)</td>
				</tr>
				<tr>
					<td class="table-label">Remarques</td>
 
					<td>{{vehicule.remarques}}</td>
				</tr>
				<tr>
					<td class="table-label">Localisation</td>
 
					<td>{{vehicule.localisation}}</td>
				</tr>
				<tr>
					<td class="table-label">Critère pollution / energétique</td>
 
					<td>{{vehicule.criterepollution}}</td>
				</tr>
 
			</tbody>
		</table>
 
		{# Liste d'options du véhicule #}
		<table class="table liste-options-vehicules">
			<tbody>
				{% for option in vehicule.listeOptionsVehicule %}
							{{dump(option.optionvehicule)}}	
					{% if option %}
						<tr>
							<td>Option :
								{{option.optionvehicule}}</td>
						</tr>
					{% endif %}
				{% endfor %}
			</tbody>
		</table>
 
	{% endblock %}