The Blog

Laravel

Laravel

Laravel String Helper Function: upper

John Koster
John Koster
November 16, 2016

The upper method in PHP's Laravel Framework is used to convert a given value to uppercase. It is the opposite of the lower method and can be used for string comparisons. By using Str::upper('all upper cased'), the string "all upper cased" will be converted to "ALL UPPER CASED".

Laravel

Laravel String Helper Function: words

John Koster
John Koster
November 16, 2016

Learn how to limit the number of words returned in a string with the words helper method in Laravel. Similar to the limit function, words allows you to specify the maximum number of words you want to display. Check out the code example to see it in action.

Laravel

Laravel String Helper Functions

John Koster
John Koster
November 16, 2016

Learn about the string helper functions in Laravel that can simplify common string operations in PHP. These functions, found in the static class Illuminate\Support\Str, include useful methods like checking if a string contains a substring, or if a string starts or ends with another string. Laravel's string helper functions treat string values as immutable, meaning that a new, modified copy of the string will be returned from the function. Find out more about these powerful tools in this informative post.

Laravel

Laravel Translation Helper Function: trans

John Koster
John Koster
November 16, 2016

Learn how to use the trans helper function to retrieve translations in Laravel. The function takes a $key parameter corresponding to an array key, and allows for replacements with the $parameters array parameter. Specify the desired locale with the $locale parameter. Explore examples of using the $parameters parameter to replace placeholders in translations. Remember that the placeholder name in $parameters should not include the : character.

Laravel

Laravel Translation Helper: trans_choice

John Koster
John Koster
November 16, 2016

Learn how to use the trans_choice helper function in Laravel to pluralize and translate a given string based on a specific locale. This function accepts the $id of the string to be translated and the $number of objects in the collection, as well as optional replacements. Pluralized strings can contain multiple messages separated by the | character, allowing for different messages to be displayed for different numbers. To retrieve the correct message, provide the appropriate $number and any necessary replacements in the function call. Apply this helper function in your Laravel projects to handle pluralization and translation with ease.

Laravel

Special Cases for Laravel's Pluralization Features

John Koster
John Koster
November 16, 2016

This table lists words and word endings that are not affected by the plural method. Some words already exist in their plural form, while others do not have an inflection available. Additionally, there are some special cases where the method handles the inflection differently for words like "atlas" and "child."

Laravel

Special Cases for Laravel's Singular Pluralization Feature

John Koster
John Koster
November 16, 2016

This table lists word endings that will not be affected by the singular method. It includes various word endings like -*ese*, -*ese*, -*ese*, and -*nese*. Additionally, there are special cases where certain words do not have a clear method of handling inflection, such as *brothers*, *children*, *genus*, and *people*.

Laravel

Calculating Averages Using Collections in Laravel

John Koster
John Koster
March 23, 2016

Learn how to use the avg method in Laravel collections to calculate the average value of items. You can use the optional $key parameter to specify which property of the collection to average. If no key is provided, the method assumes the collection contains numeric values and averages all items. The avg method also works on collections of objects using the same syntax. Additionally, you can use "dot" notation to average nested properties in arrays or objects.

Laravel

Semantic UI Paginator for Laravel 4

John Koster
John Koster
December 13, 2014

Learn how to create a custom paginator for Semantic UI in Laravel 4 with this step-by-step tutorial. The tutorial provides the necessary HTML markup and code snippets, along with explanations, to guide you through the process. By the end, you'll have a Paginator that generates Semantic UI compatible markup.

Laravel

Laravel and Kint Debugging

John Koster
John Koster
September 20, 2014

Learn how to enhance your Laravel development workflow by integrating Kint, a powerful debugging tool. Follow the steps provided in this tutorial to require Kint in your project and modify one of its functions to work seamlessly with Laravel. Discover how to use the new lk() function as a replacement for Laravel's dd() function to display detailed Kint table breakdowns. Improve your debugging experience with this simple yet effective solution.

Latest posts

That Escalated Quickly: All the New Things

The past six months or so have been incredibly busy. What started as a new article series about cust...

Read more
Troubleshooting a Statamic Illegal Offset Type Error when Viewing Collection Entries in the Control Panel

In this post I talk about how I resolved a mysterious illegal offset type error when viewing collect...

Read more
Creating Simple HTTP Redirect Routes from a Statamic Site

Generating a custom Laravel routes file from a Statamic website to redirect to a new domain.

Read more
Disabling Vite File Hashes

Disabling file hashes in Vite output can be accomplished by modifying your project's vite.config.js

Read more
Implementing a Custom Laravel Blade Precompiler for Volt and Livewire

Learn how to implement a custom component compiler for Laravel's Blade templating language in this p...

Read more
Creating a Hybrid Cache System for Statamic: Part Five

Part 5 of 6 covers implementing a cache namespace and labeling system, which we can use to target mu...

Read more