2 pièce(s) jointe(s)
INSERT INTO : Définir les champs
Bonjour,
J'ai récupéré un projet Symfony, mais je n'arrive pas à insérer des données à l'intérieur car les champs visés par l'insertion ne correspondent pas à ceux dans ma table. Seulement, j'ai beau faire des grep -r, vider le cacher, je ne trouve pas à quel moment les noms de colonnes sont inscrits en symfony pour être insérés (les colonnes lien_fichier, cours_id, plage_horaire_justif_abscence_id, utilisateur_etudiant_id, formation_id, que je souhaiterai modifié conformément à ma table).
Mon erreur:
Pièce jointe 542062
Ma table et ses colonnes :
Pièce jointe 542065
Mon Controller (PanelEtudiantController.php)
Code:
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
|
<?php
namespace App\Controller;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\Constraints\DateTime;
use Symfony\Component\HttpFoundation\Session\Session;
use App\Entity\Pointage;
use App\Entity\PlageHoraire;
use App\Entity\Utilisateur;
use App\Entity\AbscencesJustif;
use App\Form\JustifAbscence;
use App\Form\PointageNullType;
use App\Form\PointageDeSortieType;
use DateTimeImmutable;
class PanelEtudiantController extends AbstractController
{
public function panelEtudiant()
{
$user = $this->getUser();
$utilisateurEtudiant = $this->getDoctrine()->getRepository(Utilisateur::class)->find($user);
$idPointage = $this->getDoctrine()->getRepository(Pointage::class)->findPointageSortieByEtudiant($utilisateurEtudiant);
if($idPointage != null){
$pointageExistant = $this->getDoctrine()->getRepository(Pointage::class)->find($idPointage[0]);
$cours = $pointageExistant->getCours();
return $this->render('panelEtudiant.html.twig', array('message' => 'Vous avez pointé en entrée de cours :', 'cours' => $cours, 'prenom' => $user->getPrenomUtilisateur(), 'nom' => $user->getNomUtilisateur()));
} else {
return $this->render('panelEtudiant.html.twig', array('message' => 'Vous n\'avez pas de pointage pour le moment', 'cours' =>'', 'prenom' => $user->getPrenomUtilisateur(), 'nom' => $user->getNomUtilisateur()));
}
}
public function justifierAbscence(Request $request, EntityManagerInterface $em): Response
{
//$session = $this->get('session');
$user = $this->getUser();
$abscence_justif = new AbscencesJustif();
//$user = $this->getDoctrine()->getRepository(Utilisateur::class)->find($id);
$idPointage = $this->getDoctrine()->getRepository(AbscencesJustif::class)->findPointageSortieByEtudiant($user);
$idPointageNull = $this->getDoctrine()->getRepository(AbscencesJustif::class)->findPointageByEtudiant($user);
$formation = $user->getFormation();
$form = $this->createForm(JustifAbscence::class, $abscence_justif, ['formation' => $formation]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$abscence_justif = $form->getData();
$cours = $form['cours']->getData()->getNomUe();
$plageHoraireJustifAbscence = $form['plageHoraire']->getData()->getPlageHoraire();
$tab = explode("h", $plageHoraireJustifAbscence, 2);
$pointageTemporaire = new \DateTime();
$abscence_justif->setFormation($formation);
$abscence_justif->setUtilisateurEtudiant($user);
$em = $this->getDoctrine()->getManager();
$em->persist($abscence_justif);
$em->flush();
return $this->redirectToRoute('panelEtudiant');
}
return $this->render('panelEtudiantJustifierAbscence.twig', [
'nom' => $user->getNomUtilisateur(),
'prenom' => $user->getPrenomUtilisateur(),
'form'=>$form->createView(),
]);
}
} |
Entité (AbscencesJustif.php)
Code:
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
|
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\PointageRepository")
*/
class AbscencesJustif
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Cours", inversedBy="pointage")
* @ORM\JoinColumn(nullable=false)
*/
private $cours;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\PlageHoraire", inversedBy="pointage")
* @ORM\JoinColumn(nullable=false)
*/
private $plageHoraireJustifAbscence;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur", inversedBy="pointage")
*/
private $utilisateurEtudiant;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Formation", inversedBy="pointages")
* @ORM\JoinColumn(nullable=false)
*/
private $formation;
/**
* @ORM\Column(type="boolean")
*/
private $lienFichier;
public function __construct()
{
}
public function getId(): ?int
{
return $this->id;
}
public function getDateJustif(): ?\DateTimeInterface
{
return $this->dateJustif;
}
public function setDateJustif(\DateTimeInterface $dateJustif): self
{
$this->dateJustif = $dateJustif;
return $this;
}
public function getCours(): ?Cours
{
return $this->cours;
}
public function setCours(?Cours $cours): self
{
$this->cours = $cours;
return $this;
}
public function getUtilisateurEtudiant(): ?Utilisateur
{
return $this->utilisateurEtudiant;
}
public function setUtilisateurEtudiant(?Utilisateur $utilisateurEtudiant): self
{
$this->utilisateurEtudiant = $utilisateurEtudiant;
return $this;
}
public function getPlageHoraire(): ?PlageHoraire
{
return $this->plageHoraireJustifAbscence;
}
public function setPlageHoraire(?PlageHoraire $plageHoraireJustifAbscence): self
{
$this->plageHoraireJustifAbscence = $plageHoraireJustifAbscence;
return $this;
}
public function getLienFichier(): ?bool
{
return $this->lienFichier;
}
public function setLienFichier(bool $lienFichier): self
{
$this->lienFichier = $lienFichier;
return $this;
}
public function getFormation(): ?Formation
{
return $this->formation;
}
public function setFormation(?Formation $formation): self
{
$this->formation = $formation;
return $this;
}
} |
Vue (panelEtudiantJustifierAbscence.php)
Code:
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
|
{% extends 'base.html.twig' %}
{% block title %}CHRONOS ADMIN - Dashboard{% endblock %}
{% block stylesheetsAdmin %}
<link rel="stylesheet" href={{ asset('css/sb-admin-2.min.css') }}>
{% endblock %}
{% block body %}
<!-- Page Content -->
<div class="container">
<!-- Jumbotron Header -->
<header class="jumbotron my-4">
<a href="{{ path('logout') }}" class="btn btn-sm btn-danger float-right">Quitter</a>
<h1 class="display-3">Justifier une abscence</h1><br /><br />
<!-- <p class="lead">Sélectionnez le cours pour visualiser les pointages effectués aujourd'hui pour ce cours.</p> -->
<div class="row justify-content-md-center">
<div class="col-xl-6 col-md-3 mb-4">
<div class="card border-left-primary shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="login d-flex align-items-center py-5">
<div class="container">
<div class="row">
<div class="col-md-12 col-lg-12 mx-auto custom-fade">
<section class="pricing">
<div class="container">
{{ form_start(form) }}
<div class="form-label-group" style="margin-bottom:10px">
{{ form_widget(form.cours) }}
</div>
<div class="form-label-group" style="margin-bottom:10px">
{{ form_widget(form.plageHoraire) }}
</div>
<div class="form-label-group" style="margin-bottom:10px">
<input type="file" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
</div>
<div class="form-label-group">
{{ form_widget(form.connection) }} <a href="{{ path('panelEtudiant') }}" class="btn btn-light text-uppercase ml-2 px-2">Annuler</a>
</div>
{{ form_end(form) }}
</div>
</section>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</header>
</div>
{% endblock %} |
Merci d'avance