Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Here my code :
$validated = request()->validate([ 'q' => 'required|string', ]);
I want the same without using an array. I tried this :
$validated = request()->validate('q', 'required|string');
Thank's for your help.
You can use $request->has() to check if a parameter has been sent.
$request->has()
$request->has('q');
Request parameters are all strings by default, but you can do an extra check for null by using get with a default value.
null
if ($request->get('q', null) !== null) { // $q is set! }
Add a comment
request()->has('q')
Required, but never shown
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.
Explore related questions
See similar questions with these tags.