D
D
Dmitry2021-09-27 21:40:42
symfony
Dmitry, 2021-09-27 21:40:42

How to get the correct parameter in the Repository?

Good evening.

Help solve the problem.
There is an action in the controller in which I need to get three parameters and delete the entry from the database.
In the form template, the route is specified in the action

<form action="{{ url('memorials.detach', {id: memorial.id, user_id: user.user, role: user.role}) }}"


In the controller in the Route annotation
/**
     * @Route("/detach/{id}/{user_id}/{role}", name=".detach", methods={"DELETE"})
     * @param Request $request
     * @param string $user_id
     * @param string $role
     * @param Detach\Handler $handler
     * @return Response
     */
    public function detach(Request $request, string $id, string $user_id, string $role, Detach\Handler $handler): Response


It is required to delete the record by $id, but $user_id is passed to the repository.

How to get $id in repository?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2021-09-27
@slo_nik

You are incorrectly substituting the ID below in the controller/service/repository.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question