Singular and Plural Word Forms
Learn how to convert words to their singular or plural forms with the help of examples.
We'll cover the following
In addition to the string translation helper methods and supporting features, Laravel provides simple ways to convert words to their singular or plural forms. By default, this feature works for English words, but we can enable it for Norwegian Bokmål, French, Portuguese, Spanish, and Turkish.
Laravel utilizes the Doctrine Inflector package under the hood and provides additional features (such as working with studly cased words) and a simple wrapper around its features.
To configure the pluralization language, we will need to instruct Laravel to use the language within the application’s service provider. Changing the language affects other features within the framework, such as the Eloquent ORM. The official documentation provides more information on how to change the language and coverage of which features this setting impacts.
The three methods we use to interact with the pluralization features are plural
, pluralStudly
, and singular
. We will start our discussion with the singular
helper method.
Get hands-on with 1200+ tech skills courses.