0

I am trying to remove the url parameters based on some conditions ,i can able to remove some of the parameters , i want to replace the some new value for the url, can you please give me some idea how to do this one

$request->query->remove('key');
$request->query->add(['admin'=>"true"]);
$request->request->remove('key');
$request->request->add(['admin'=>"true"]);
7
  • Does something not work? What is the actual output after updating? Commented Feb 1, 2022 at 10:14
  • after updating it will fetch admin users whose value is true Commented Feb 1, 2022 at 10:17
  • You showed your "Expected output", what is the actual output /URL after you ran the code you posted? Commented Feb 1, 2022 at 10:21
  • @brombeer, i updated the question please take a look Commented Feb 1, 2022 at 10:29
  • That still isn't the actual URL you get after running your code. Your question is about how to replace query parameters. You have http://localhost.com/users?limit=25&page=1&search=xyz, you apply the code you posted, is something not replaced? What does the request/url look like after that? (Might be I'm completely misunderstanding your question) Commented Feb 1, 2022 at 10:34

1 Answer 1

1

You almost done in a correct way, simply change the order of the queries then it will be working fine.

$request->query->remove('key');
$request->request->remove('key');
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @Sai Tarun, it's working fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.