The blog

Integrating Laravel Spark, Stripe, and Statamic 3

Feb 20, 2021

In this article we will start with a fresh Statamic 3 website based on the Cool Writings Starter Kit, integrate Laravel Stripe, and develop customer Antlers tags that can be used to selectively restrict access to premium content.
Implementing a Customer Domain Specific Language Parser in PHP

Feb 15, 2021

Implementing a custom domain specific language parser in PHP, from scratch. Our language parser will parse a custom query filter language.
Implementing C# Events

Jan 7, 2021

C#'s event features are an elegant wrapper around the delegate type, making it incredibly simple to create custom events, and consume existing events.
Creating a Custom Statamic 500 Server Error Page

Dec 29, 2020

Customizing a Statamic site's 500 Server Error page is a relatively simple process, as well as developing a custom Antlers tag to help test it.
Laravel 5 Collections: Adding an Element to the Beginning of a Collection With prepend

Apr 22, 2018

The prepend method in Laravel's Collection class allows you to add a given value to the beginning of the collection. It also accepts an optional key parameter for adding items to the beginning of an associative array. The method returns a reference to the original collection instance. In the provided code examples, a new item is added to the beginning of the collection using prepend, and the resulting collection is printed. In another example, an item is added to the beginning of an associative array with a specified key using prepend, and the resulting collection is printed.
Laravel 5 Collections: Adding an Element to the End of a Collection With push

Apr 22, 2018

The push method in Laravel is used to add an item to the end of a collection. It returns a reference to the original collection instance. However, it cannot be used to set the key of the item being added. To use the push method, you create a new collection instance, and then call the push method on it, passing the item you want to add as a parameter. After the push method is executed, the collection will be modified with the new item added at the end.
Laravel 5 Collections: Adding New Elements to a Collection With put

Apr 22, 2018

The put method in the Laravel Collection class allows you to add a new item to the collection with a specified key and value. This method modifies the original Collection instance and returns a reference to it. With an example use case, you can see how the put method works in practice, by adding a new item to the collection. After executing the code, the collection would contain the added item alongside existing ones.
Laravel 5 Collections: Adding Values to a Collection With union

Apr 22, 2018

Learn how to use the union method in Laravel collections. This method adds the provided items to a copy of the existing collection, without modifying the original collection. If there are key collisions, the elements from the original collection will be used. Check out an example use case and see how union works.
Laravel 5 Collections: Breaking a Collection Into a Specified Number of Groups With split

Apr 22, 2018

The split method in Laravel is used to break a collection into a smaller number of collections. With the split method, you can specify the number of groups you want the collection split into. If there are no items in the collection, it will return a new, empty collection instance. In the example provided, a collection is split into two groups, each containing elements from the original collection.
Laravel 5 Collections: Calculating the Average Value of a Collection With average

Apr 22, 2018

The average method in PHP is an alias of the avg method. It calculates the average value of a collection and can be used in the same way. For example, you can use it to find the average of a array of numbers. Additionally, the average method can also be used with higher order messaging, which allows you to easily calculate the average price of a collection of objects using PHP's property accessors syntax.
Laravel 5 Collections: Calculating the Average Value of a Collection With avg

Apr 22, 2018

The avg method in Laravel allows you to calculate the average value of items in a collection. It can be used with both arrays and objects. You can also specify a key to average nested properties. Additionally, you can use higher order messaging to easily calculate the average of a specific property in a collection of objects.
Laravel 5 Collections: Calculating the Median Value of a Collection With median

Apr 22, 2018

The median method in PHP can be used to calculate the median value of a collection of data. It allows you to find the value that separates the higher and lower halves of the data. You can also specify a key to limit the calculation to nested property values. In the provided example, the median method is used to find the median value of both a collection of numbers and a collection of test scores.
Laravel 5 Collections: Calculating the Minimum Value of a Collection With min

Apr 22, 2018

The min method in Laravel is the opposite of the max method and accepts the same number of arguments. It can be used to retrieve the minimum value of a given key. If no key is specified, it will function similarly to PHP's min function. In the code examples provided, it shows how to use the min method both with and without specifying a key.
Laravel 5 Collections: Calculating the Sum of a Collection With sum

Apr 22, 2018

The sum method in Laravel's Collection class returns the sum of all items in the collection. It can also accept a callback function to specify which values should be added together. If the collection is empty, the method will return 0. In the first example, the code shows a simple usage of the sum method to calculate the sum of numbers in the collection. In the second example, the code demonstrates how to use the sum method to calculate the total number of speakers at a conference. The third example shows how the sum method can be used with a higher order message to calculate the sum of speakers at multiple conferences.

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.