Hidden Methods

Useful methods buried deep in the framework that most developers never discover.

Beginner Since 5.3

The tap() Helper

Call a closure on a value and return the value, not the closure result. Perfect for chaining side-effects without breaking a fluent chain.

Collections Helpers
Beginner Since 9.x

Str::squish()

Collapse all consecutive whitespace (including newlines and tabs) into a single space and trim the result.

Helpers
Intermediate Since 10.x

Number::pairs()

Split a numeric range into evenly sized chunks as start/end pairs — great for batch processing and pagination math.

Performance Helpers
Beginner Since 11.x

The once() Helper

Memoize the result of an expensive expression so it only executes once per request, no matter how many times it is called.

Performance Helpers
Beginner Since 9.x

Arr::undot()

Expand a flat dot-notation array back into a fully nested structure — the inverse of Arr::dot().

Collections Helpers
Intermediate Since 8.x

Collection::sole()

Get exactly one matching item from a collection — or throw an exception. A stricter alternative to first().

Collections Database
Beginner Since 10.x

Str::password()

Generate a cryptographically secure random password with configurable length and character types.

Security Helpers
Intermediate Since 9.x

Fluent Strings: whenContains()

Conditionally transform a string only if it contains a given substring — part of the powerful Stringable fluent API.

Helpers
Intermediate Since 10.x

FormRequest::after()

Run additional validation logic after your rules pass — perfect for complex, cross-field checks that don't fit neatly into a single rule.

Validation
Advanced Since 9.x

Rule::forEach()

Apply dynamic validation rules to each element in a nested array — with access to the item's value and fully-expanded attribute name.

Validation
Beginner Since 5.5

The rescue() Helper

Execute a closure and swallow any exceptions, optionally returning a fallback value — a try/catch in a single expression.

Helpers Error Handling
Beginner Since 9.x

Str::mask()

Mask a portion of a string with a repeated character — ideal for obscuring emails, phone numbers, or sensitive data.

Security Helpers