The Laravel framework contains many useful helper functions, features and utility classes (such as Collections) - not all of these are well known. This book exposes these helper utilities to encourage accelerated application development using the Laravel framework (version 5.3).
Through the Laravel Companion you will learn about collections, facades, application helper functions, request and URL helper functions and much, much more.
If you've ever thought there "has to be an easier way" - there probably is in the form of a helper utility.ascii($value)
studly($value)
camel($value)
snake($value, $delimiter = '_')
title($value)
slug($title, $separator = '-')
contains($haystack, $needles)
endsWith($haystack, $needles)
startsWith($haystack, $needles)
finish($value, $cap)
is($pattern, $value)
length($value)
limit($value, $limit = 100, $end = '...')
words($value, $words = 100, $end = '...')
lower($value)
upper($value)
plural($value, $count = 2)
singular($value)
singular
Special Cases random($length = 16)
quickRandom($length = 16)
randomBytes($length = 16)
equals($knownString, $userInput)
parseCallback($callback, $default)
replaceFirst($search, $replace, $subject)
replaceLast($search, $replace, $subject)
substr($string, $start, $length = null)
ucfirst($string)
trans($id = null, $parameters = [], $domain = 'messages', $locale = null)
trans_choice($id, $number, array $parameters = [], $domain = 'messages', $locale = null)
e($value)
add($array, $key, $value)
build($array, callable $callback)
divide($array)
collapse($array)
dot($array, $prepend = '')
except($array, $keys)
only($array, $keys)
flatten($array)
fetch($array, $key)
first($array, callable $callback = null, $default = null)
last($array, callable $callback = null, $default = null)
has($array, $key)
set(&$array, $key, $value)
forget(&$array, $keys)
get($array, $key, $default = null)
pull(&$array, $key, $default = null)
pluck($array, $value, $key = null)
where($array, callable $callback)
sort($array, callable $callback)
isAssoc(array $array)
accessible($value)
exists($array, $key)
prepend($array, $value, $key = null)
app($make = null, $parameters = [])
auth($guard = null)
policy($class)
app_path($path = '')
base_path($path = '')
config_path($path = '')
database_path($path = '')
public_path($path = '')
storage_path($path = '')
abort($code, $message = '', array $headers = [])
abort_if($boolean, $code, $message = '', array $headers)
abort_unless($boolean, $code, $message = '', array $headers)
abort
, abort_if
and abort_unless
redirect($to = null, $status = 302, $headers = [], $secure = null)
back($status = 302, $headers = [])
response($content = '', $status = 200, array $headers = [])
request($key = null, $default = null)
view($view = null, $data = [], $mergeData = [])
old($key = null, $default = null)
event($event, $payload = [], $halt = false)
dispatch($command)
factory()
method_field($method)
validator(array $data = [], array $rules = [], array $messages = [], array $customAttributes = [])
bcrypt($value, $options = [])
encrypt($value)
decrypt($value)
csrf_field()
csrf_token()
session($key = null, $default = null)
cookie($name = null, $value = null, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true)
config($key = null, $default = null)
env($key, $default = null)
logger($message = null, $context = [])
info($message, $context = [])
action($name, $parameters = [], $absolute = true)
asset($path, $secure = null)
secure_asset($path)
url($path = null, $parameters = [], $secure = null)
secure_url($path, $parameters = [])
elixir($file, $buildDirectory = 'build')
route($name, $parameters = [], $absolute = true, $route = null)
dd()
data_get($target, $key, $default = null)
data_set(&$target, $key, $value, $overwrite = true)
data_fill(&$target, $key, $value)
object_get($object, $key, $default = null)
trait_uses_recursive($trait)
value($value)
with($object)
windows_os
tap($value, $callback)
all
toArray
chunk($size, $preserveKeys = false)
collapse
contains($key, $value = null)
count
diff($items)
diffKeys($items)
each(callable $callback)
filter(callable $callback = null)
first(callable $callback = null, $default = null)
flatten
flip
forPage($page, $perPage)
forget($key)
get($key, $default = null)
groupBy($groupBy, $preserveKeys = false)
has($key)
implode($value, $glue = null)
intersect($items)
isEmpty
jsonSerialize
keys
last(callable $callback = null, $default = null)
lists($value, $key = null)
map(callable $callback)
max($key = null)
merge($items)
min($key = null)
pluck($value, $key = null)
pop
prepend($value, $key = null)
pull($key, $default = null)
push($value)
put($key, $value)
random($amount = 1)
reduce(callable $callback, $initial = null)
reject($callback)
reverse
search($value, $strict = false)
shift
shuffle
slice($offset, $length = null, $preserveKeys = false)
sort(callable $callback = null)
sortBy($callback, $options = SORT_REGULAR, $descending = false)
sortByDesc($callback, $options = SORT_REGULAR)
splice($offset, $length = null, $replacement = [])
avg($key = null)
average($key = null)
sum($callback = null)
take($limit)
toJson($options = 0)
__toString()
transform(callable $callback)
unique($key = null)
values
where($key, $operator, $value = null)
whereLoose($key, $value)
zip($items)
combine($values)
every($step, $offset = 0)
except($keys)
only($keys)
keyBy($keyBy)
whereIn($key, array $values, $strict = true)
whereInLoose($key, array $values)
make($items = [])
Illuminate\Contracts\Support\MessageProvider
Interface Fluent
Public API Macroable
Methods Covering topics from JavaScript to Laravel, and everything in-between since 2012.