Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class CollabController extends AbstractController
- {
- /**
- * @Route("/editmatform", name="collab_edit_mat_form", methods={"GET","POST"})
- */
- public function editmatform(Request $request)
- {
- $em = $this->getDoctrine()->getManager();
- $id_collab = $request->request->get("collab");
- $retiremat = $request->request->get("cbRetiremat");
- $addMat = $request->request->get("cbAddmat");
- /** @var \App\Entity\Collab $collab */
- $collab = $em->getRepository(Collab::class)->find($id_collab);
- $materiels = $collab->getMateriels();
- if (! $retiremat) {
- return $this->redirectToRoute('collab_edit_mat', ['id' => $id_collab]);
- }
- foreach ($materiels as $materiel) {
- if (in_array($materiel->getId(), $retiremat, false)) {
- $collab->removeMteriel($materiel);
- }
- $em->flush();
- }
- return $this->redirectToRoute('collab_edit_mat', ['id' => $id_collab]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement