The blog

Laravel 5: Getting Array or Object Values With data_get

Apr 15, 2018

The data_get function is a versatile tool that allows you to retrieve values from both objects and arrays in PHP. It has the same behavior as the array_get and object_get functions, but it accepts both objects and arrays as its $target input value. You can also supply a default value to use if the key doesn't exist in the target. The function is easy to use and can greatly simplify your code when working with both objects and arrays.
Laravel 5: Getting the Class Name for an Object Instance With class_basename

Apr 15, 2018

Learn how to use the class_basename function in PHP to retrieve the name of a class. The function accepts a class and returns its base name. Check out the provided examples to see how it works with different classes and objects.
Laravel 5: Getting the Current Date and Time With now

Apr 15, 2018

The now helper function in PHP returns a new Carbon instance that represents the current date and time. It can also accept an optional timezone parameter to adjust the timezone of the returned date. Learn how to use the now helper function with an example that shows how to get the current Atom formatted date and time, as well as how to get the current date and time for a specific timezone.
Laravel 5: Provide Default Values for Object Properties With optional

Apr 15, 2018

The optional function in Laravel returns a new instance of Illuminate\Support\Optional with the provided value. It allows you to easily retrieve a default or null value on method return values or object properties that may not exist. This can be useful when displaying data or returning results that might not exist at runtime. The Optional class also implements the Illuminate\Support\Traits\Macroable trait, allowing you to add functionality to the Optional instance at runtime.
Laravel 5: Retrieving Object Values With object_get

Apr 15, 2018

The object_get function allows developers to retrieve properties from a given object using dot notation. It is useful when the existence of a specific property in the object cannot be guaranteed. With object_get, you can easily access nested properties of an object. If a property does not exist, you can provide a default value to be returned instead.
Laravel 5: Retrieving the Default Value of a Given Variable With value

Apr 15, 2018

The value function in PHP retrieves the default value of a given variable. If the variable is an anonymous function, it will be executed and the resulting value will be returned. Otherwise, the function will simply return the variable as is. An example using an anonymous function and another example using a regular variable are provided.
Laravel 5: Returning In-line Access to a Variable With with

Apr 15, 2018

Learn how to use the with function in PHP to simplify method chaining and return values without creating temporary variables. The with function can be helpful when passing new class instances as function arguments. It can also accept a callback function to perform additional actions or mutate the value before returning it. An alternative to the with function is wrapping object instantiation within parentheses. The with function can improve code readability and clarify intent. Use the example provided to learn how to get a weather forecast using the Yahoo weather API and the with function.
Laravel 5: Setting Array or Object Values With data_set

Apr 15, 2018

The data_set function allows you to set the value of an item in an array or object property using dot notation. It accepts a reference to the target array or object, the key of the data to set, and the value to be set. By default, existing values for the key will be replaced, but you can choose to overwrite or not. The function can also handle nested properties and can be used with objects as well.
Laravel 5: Setting Data on Objects Without Overwriting Existing Data With data_fill

Apr 15, 2018

The data_fill helper function is used to set data in a target object. It is similar to the data_set helper function, but it does not overwrite existing data. The function takes three parameters: the target object, the key to set, and the value to set. When called, data_fill internally uses data_set with the overwrite flag set to false. An example use case is demonstrated where data is set using both data_fill and data_set with the same result.
Laravel 5: Accessing and Manipulating Configuration Values With config

Apr 14, 2018

The config function in Laravel can be used to resolve an instance of the configuration repository from the Service Container, or to get or set configuration values at runtime. It has multiple signatures allowing for different usage scenarios. When used without any arguments, it returns an instance of the configuration repository. The function can also be used to set configuration values by providing an array of key/value pairs, and it can retrieve configuration values by providing a key, with an optional default value if the key does not exist.
Laravel 5: Accessing and Manipulating Session Data With session

Apr 14, 2018

The session function in Laravel allows you to resolve the session manager instance from the service container, retrieve session values, and set new session values. You can return an instance of the session manager class by setting the $key parameter to null. To set session values, you can pass an array of key/value pairs to the session function. Retrieving session values is done by supplying a $key to the function call, and you can provide a default value in case the session value does not exist.
Laravel 5: Accessing and Sending HTTP Responses With response

Apr 14, 2018

The response helper function in Laravel is a versatile function that can be used to accomplish different tasks. When called without any arguments, it returns an instance of "Illuminate\\Contracts\\Routing\\ResponseFactory" by default. It can also be used as a shortcut to the ResponseFactory::make method by passing content, status, and headers as arguments. Additionally, you can change the HTTP status code and supply additional headers when using the response function.
Laravel 5: Accessing HTTP Request Details With request

Apr 14, 2018

The request helper function allows you to retrieve either an instance of Illuminate\Http\Request or an item from the user's input. To retrieve an instance of Request, call the request method without arguments. To retrieve an input value, provide at least the $key argument. The helper function can also be used as a shortcut for the Request::input method, with examples given. Additionally, the request function allows you to access a subset of the user's input data by using the only method or by providing an array as the only argument.
Laravel 5: Accessing Session Input Data With old

Apr 14, 2018

The old helper function in Laravel is used to retrieve an old input item. It accepts a key argument and an optional default value. You can use it to easily retrieve old input data by specifying the key of the input item you want to retrieve. If no key is specified or the specified key does not exist, the function will return the provided default value or null. There are multiple ways to use the old helper function, including using the Input facade or the request() helper function.

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.