Skip to content

Instantly share code, notes, and snippets.

@sunshain
Last active April 22, 2016 11:45
Show Gist options
  • Save sunshain/eb48ff2145f6c26690e92a5c9c6bffc7 to your computer and use it in GitHub Desktop.
Save sunshain/eb48ff2145f6c26690e92a5c9c6bffc7 to your computer and use it in GitHub Desktop.
Laravel helpers, which are not written in the documentation.

Laravel helpers, which are not written in the documentation.

Support

append_config(array Array)
  • @return array
  • Assign high numeric IDs to a config item to force appending.
array_last(array Array, callable Callback = null, mixed Default = null)
  • @return mixed
  • Return the last element in an array passing a given truth test.
array_prepend(array Array, mixed Value, mixed Key = null)
  • @return array
  • Push an item onto the beginning of an array.
class_uses_recursive(string Class)
  • @return array
  • Returns all traits used by a class, its subclasses and trait of their traits.
data_fill(mixed Target, string|array Key, mixed Value)
  • @return mixed
  • Fill in data where it's missing.
data_get(mixed Target, string|array Key, mixed Default = null)
  • @return mixed
  • Get an item from an array or object using "dot" notation.
data_set(mixed Target, string|array Key, mixed Value, bool Overwrite = true)
  • @return mixed
  • Set an item on an array or object using dot notation.
object_get(object Object, string Key, mixed Default = null)
  • @return mixed
  • Get an item from an object using "dot" notation.
preg_replace_sub(string Pattern, array Replacements, string Subject)
  • @return string
  • Replace a given pattern with each value in the array in sequentially.
str_replace_array(string Search, array Replacements, string Subject)
  • @return string
  • Replace a given value in the string sequentially with an array.
str_replace_first(string Search, array Replacements, string Subject)
  • @return string
  • Replace the first occurrence of a given value in the string.
str_replace_last(string Search, array Replacements, string Subject)
  • @return string
  • Replace the last occurrence of a given value in the string.
title_case(string Value)
  • @return string
  • Convert a value to title case.
trait_uses_recursive(string Trait)
  • @return array
  • Returns all traits used by a trait and its traits.
windows_os()
  • @return bool
  • Determine whether the current envrionment is Windows based.

Fountation

abort(int Code, string Message = '', array Headers = [])
  • @return void
  • @throws Symfony\Component\HttpKernel\Exception\HttpException
  • @throws Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  • Throw an HttpException with the given data.
abort_if(bool Boolean, int Code, string Message = '', array Headers = [])
  • @return void
  • @throws Symfony\Component\HttpKernel\Exception\HttpException
  • @throws Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  • Throw an HttpException with the given data if the given condition is true.
abort_unless(bool Boolean, int Code, string Message = '', array Headers = [])
  • @return void
  • @throws Symfony\Component\HttpKernel\Exception\HttpException
  • @throws Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  • Throw an HttpException with the given data unless the given condition is true.
app(string Make = null, array Parameters = [])
  • @return mixed | Illuminate\Foundation\Application
  • Get the available container instance.
cookie(string Name = null, string Value = null, int Minutes = 0, string Path = null, string Domain = null, bool Secure = false, bool HttpOnly = true)
  • @return Symfony\Component\HttpFoundation\Cookie
  • Create a new cookie instance.
decrypt(string Value)
  • @return string
  • Decrypt the given value.
encrypt(string Value)
  • @return string
  • Encrypt the given value.
info(string Message, array Context = [])
  • @return void
  • Write some information to the log.
logger(string Message = null, array Context = [])
  • @return Illuminate\Contracts\Logging\Log | null
  • Log a debug message to the logs.
policy(object|string Class)
  • @return mixed
  • @throws InvalidArgumentException
  • Get a policy instance for a given class.
resource_path(string Path = '')
  • @return string
  • Get the path to the resources folder.
secure_url(string Path, array Parameters = [])
  • @return string
  • Generate a HTTPS url for the application.
validator(array Data = [], array Rules = [], array Messages = [], array CustomAttributes = [])
  • @return Illuminate\Contracts\Validation\Validator
  • Create a new Validator instance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment