Laravel Helper Function: env Nov 20, 2016
The env function in Laravel retrieves the value of an environment variable, returning the value if it exists or a default value if it does not. It supports automatic conversion of boolean string representations and null values to their respective PHP types. Examples are shown using a .env file, demonstrating the function's usage and defaults.
Laravel Helper Function: info Nov 20, 2016
The info helper function in Laravel allows you to write information entries into the log files. You can specify a message and an optional context, which can be an array of data. The context can even contain objects. The log entries will include the message and the context data if provided.
Laravel Helper Function: logger Nov 20, 2016
The logger helper function in Laravel is a powerful tool for logging messages. If no message is provided, the function returns a Log instance. When used to write log messages, you can pass both a message and a context. The context can be an array, and even contain arrays or objects within it. The function will output log messages in Laravel's log files.
Laravel Helper Function: session Nov 20, 2016
The session function in Laravel is a versatile function that can be used to return an instance of the SessionManager class, set session values, and retrieve session values. To return an instance of the SessionManager class, simply call the function without any parameters. To set session values, pass in an array of key/value pairs or use the put method to set a single session value. To retrieve session values, pass in the desired key to the function. If a session value does not exist, the function will return null, unless a default value is specified.
Laravel Array Helper Function: array_first Nov 19, 2016
The first helper method in Laravel is used to retrieve the first key/value pair in an array that satisfies a given callback function. The callback function can be used to check if a value matches a specific format. If no key/value pair satisfies the callback function, a default value can be returned. The callback parameter is optional, and if omitted, the method will return the first item in the array. Additionally, there is a shortcut function called array_first which is equivalent to calling Arr::first.
Laravel Array Helper Function: array_forget Nov 19, 2016
The forget helper method in Laravel is used to remove items from an array using dot notation. It is a mutable function that affects the original array. You can remove single or multiple items by passing the keys as a string or an array. There is also a shortcut function called array_forget available in the global namespace.
Laravel Array Helper Function: array_get Nov 19, 2016
The get helper method allows developers to quickly retrieve items from an array using dot notation, instead of PHP's array syntax. It is easier to read and can be customized with a default value. The array_get function is a shortcut to calling the Arr::get method in the global namespace.
Laravel Array Helper Function: array_has Nov 19, 2016
The has helper method in Laravel allows you to check if a specific key exists in an array using dot notation. It returns a boolean value indicating the existence of the key. This method is particularly useful for arrays with arbitrary depth and is easier to use than PHP's isset function. Additionally, there is a shortcut function called array_has that can be used instead of calling Arr::has.
Laravel Array Helper Function: array_last Nov 19, 2016
The last helper method in Laravel is used to retrieve the last element in an array that satisfies the given callback function. If no value satisfies the callback, a default value can be provided as well. An example usage of this method is demonstrated, showing how to get the last post from an array based on a specific format. The optional callback parameter can be omitted, in which case the method will simply return the last item in the array. Additionally, there is a shortcut function called array_last available in the global namespace that performs the same functionality as Arr::last.
Laravel Array Helper Function: array_pluck Nov 19, 2016
The pluck helper method is a convenient way to extract specific values from an array. It can be used with arrays of objects or arrays of arrays. The method can also return an array with a key/value pair based on the specified key. Additionally, pluck supports dot notation to search for keys at arbitrary depths in nested arrays or objects. There is also a global array_pluck function, which is a shortcut to calling Arr::pluck.
Laravel Array Helper Function: array_pull Nov 19, 2016
The pull helper method in Laravel is used to retrieve and remove a value from an array based on a specified key. It is similar to the get method, but with the additional functionality of removing the item from the array. This function is mutable and will affect the original array.
Laravel Array Helper Function: array_set Nov 19, 2016
The set helper method allows you to set values within an array using dot notation for the key. It is the opposite of the forget method. The set function mutates the original array and can be used to change the entire array or replace it with a different type. There is also a shortcut function called array_set available in the global namespace to call Arr::set.
Collapsing Laravel Collections using array_collapse Nov 18, 2016
Learn how to use the collapse method in Laravel's Illuminate\Support\Arr helper class to flatten arrays and collections. No special syntax is needed to use the collapse method with collections. Nested collections can also be collapsed. Find out how to implement this useful function in your Laravel projects.