Documentation Index
Fetch the complete documentation index at: https://kawax.biz/llms.txt
Use this file to discover all available pages before exploring further.
What are helpers?
Laravel ships with a large collection of global PHP helper functions. Most are used internally by the framework, but you can freely use them in your application code. Helpers fall into several categories:- Arrays & objects — the
Arr::class and functions likedata_get() - Numbers — the
Number::class - Paths —
app_path(),storage_path(), and friends - URLs —
route(),url(),asset() - Miscellaneous —
config(),collect(),auth(), and other utilities
Global helper functions need no
use declaration. The Arr and Number classes do require an import, e.g. use Illuminate\Support\Arr;.Array helpers — the Arr class
Arr::get() — read nested values with dot notation
Safely retrieves a value from a deeply nested array using dot notation. Returns a default when the key is absent.
Arr::set() — write a nested value
Arr::has() — check key existence
Arr::only() / Arr::except() — filter keys
Pick the keys you want or strip the ones you don’t. Both are handy when sanitising request data.
Arr::pluck() — extract a column
Arr::first() / Arr::last() — find by condition
Arr::flatten() — collapse nested arrays
Arr::wrap() — guarantee an array
Wraps a scalar in an array, leaves an existing array alone, and converts null to [].
Arr::sort() — sort by value or key
Arr::dot() / Arr::undot() — convert to and from dot notation
Arr::join() — join an array into a string
data_get() — access nested data anywhere
A more general version of Arr::get() that works on arrays, objects, Eloquent models, and collections.
Number helpers — the Number class
Number::format() — readable number formatting
Number::currency() — currency formatting
Number::fileSize() — human-readable file sizes
Number::abbreviate() — compact large numbers
Number::percentage() — percentage display
Path helpers
Return absolute paths to key directories. These always resolve correctly regardless of where you deploy.URL helpers
route() — generate a named route URL
url() — absolute URL for any path
asset() — public asset URL
to_route() — redirect to a named route
Commonly used helpers
config() — read and write config values
collect() — create a collection
auth() — access the authenticated user
blank() / filled() — empty checks
blank() returns true for null, empty strings, whitespace-only strings, and empty arrays/collections. filled() is the inverse.
abort() / abort_if() / abort_unless() — HTTP exceptions
dd() / dump() — debugging
dispatch() — push a job onto the queue
encrypt() / decrypt() — encryption
env() — read environment variables
Arr:: vs collect()
Use Arr:: for quick, one-off operations on a plain PHP array. Switch to collect() when you want to chain multiple transformations.
Eloquent query results already return a Collection, so there is no need to wrap them in
collect(). Use Arr:: when you only need a simple array operation without the overhead of a Collection object.Quick reference
Common helpers at a glance
Common helpers at a glance
| Helper | Purpose |
|---|---|
Arr::get($array, 'a.b.c', $default) | Read a nested key safely |
Arr::only($array, $keys) | Keep specific keys |
Arr::except($array, $keys) | Remove specific keys |
Arr::pluck($array, 'key') | Extract a column |
Arr::flatten($array) | Collapse to a flat array |
Arr::wrap($value) | Ensure a value is an array |
data_get($target, 'a.*.b') | Wildcard nested access |
Number::format($n) | Human-readable number |
Number::currency($n, 'USD') | Currency formatting |
Number::fileSize($bytes) | File size display |
route('name', $params) | Named route URL |
url('path') | Absolute URL |
asset('path') | Public asset URL |
config('key', $default) | Read a config value |
collect($array) | Create a Collection |
auth()->user() | Current authenticated user |
blank($value) | Check for emptiness |
filled($value) | Check for non-emptiness |
abort(403) | Throw an HTTP exception |
dispatch($job) | Push a job to the queue |
env('KEY', $default) | Read an env variable |
Arr:: vs collect()
Arr:: vs collect()
Use
Arr:: when:- You need a single, simple operation on a plain array
- You want the result to stay as a plain PHP array
- You do not need method chaining
collect() when:- You want to chain multiple transformations
- You are already working with Eloquent results (they are already collections)
- You need collection-specific methods like
groupBy,mapWithKeys, orzip