Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Controller;
- class DefaultController extends Controller
- {
- /**
- * @Route("/delete-client/{id}")
- */
- public function deleteAction3($id)
- {
- $em = $this->getDoctrine()->getManager();
- $client = $em->getRepository(Client::class)->find($id);
- if (!$client) {
- throw $this->createNotFoundException(
- 'There are no users with the following id: ' . $id
- );
- }
- $em->remove($client);
- $user = $em->getRepository(User::class)->findOneBy(['client' => $id]);
- if ($user) {
- $em->remove($user);
- }
- $em->flush();
- return $this->redirect('/show-client');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement