Search

Showing 7 of 1,975 result(s)

/blog/2018/04/22/laravel-5-collections-grouping-collection-elements-with-groupby

The groupBy method is used to group a collection based on a given value, represented by the $groupBy parameter. An argument passed to $groupBy can be a simple string, representing the value that the collection should be grouped by, or a callback...

/blog/2018/04/22/laravel-5-collections-retrieving-a-subset-of-a-collections-elements-with-only

The only method is the logical opposite of the except method. The only method is used to return all the key/value pairs in the collection where the keys in the collection are in the supplied $keys array. If the argument supplied for $keys...

/blog/2018/04/22/laravel-5-collections-transforming-collection-elements-with-map

The map method applies a given $callback to each item in the collection. The $callback can modify the item which will be added to a new collection. The map method does not modify the original collection, but returns a new collection instance with...

/blog/2020/12/29/creating-a-custom-statamic-500-server-error-page#content-preparing-the-local-project

It is often that when working on projects locally, the project is in debug mode. Because of this, we will see screens like this instead of our custom error page: To have our custom error page show up we need to temporarily update our .env file and...

/blog/2022/11/01/a-beginners-guide-to-antlers-arrays-and-loops#content-accessing-the-first-and-last-array-elements

Suppose we wanted to access  only  the first and last items of an array without looping through all of the items in the list. We can use the first and last modifiers to easily access the data for these items. Consider the following data: Example...

/blog/2014/07/28/laravel-paginator-pretty-urls#content-using-the-prettypaginator

Now that we have the PrettyPaginator class written, we actually need to use it. This will involve some more work, but its pretty simple. Here are the things we will need to do: Create a new Route for our pagination URL,, Create a function that...

/blog/2014/07/28/laravel-paginator-pretty-urls#content-creating-the-route

We are going to paginate a list of users. We want to display users with the URL format: http://localhost:8000/users/page/{page} . We are going to use a function called getShowResults in our UsersController . We can express this in our routes.php...