laravel plural and singular 1

laravel plural and singular

echo Illuminate\Support\Str::plural('list', 1); // list
echo Illuminate\Support\Str::plural('list', 2); // lists

Here is what the above code is Doing:
1. We’re using the Str::plural() method to pluralize the word “list”.
2. We’re passing the number 1 to the method, which means that the word “list” should be singular.
3. We’re passing the number 2 to the method, which means that the word “list” should be plural.

The Str::plural() method is smart enough to know that the word “list” should be pluralized to “lists” when the number 2 is passed to the method.

The Str::plural() method is also smart enough to know that the word “person” should be pluralized to “people” when the number 2 is passed to the method.

echo Illuminate\Support\Str::plural(‘person’, 1); // person
echo Illuminate\Support\Str::plural(‘person’, 2); // people

Similar Posts