Hello, $request->post(), by calling post() it returns only data from body, ignoring those from query string
public function store(Request $request)
{
dd($request->post());
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I am using Laravel 6.
If I do a $request->post('foo') it returns the value of "foo" in the query string.
Similarly, if I do a $request->has('foo') it returns TRUE if "foo" is set in the query string.
However I want it to ONLY look at POST data, and to ignore the query string in both cases.
How can I make it do this?
Thanks,
Martin
As you say, a GET request has no POST data so surely the "post()" method should return nothing.
Anyway, as you guessed, I have a trait function that has to work with both GET and POST requests, but cannot rely on $request->method() to determine which it is.
Either way, it appears as if that if statement is needed, so that is what I will do ...
Thanks :-)
Please or to participate in this conversation.