DEV Community

Michael
Michael

Posted on

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)