DEV Community

Michael
Michael

Posted on

1 1

Determining if multiple inputs have values with Laravel

Although it doesn't appear in the docs Laravel has a handy method to determine if the HTTP request contains one or more inputs with values:

if ($request->anyFilled(['name', 'type', 'status']) {
    //
}
Enter fullscreen mode Exit fullscreen mode

The anyFilled method will return true if any of the inputs given in the array contain a non-empty value.

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay