Laravel str plural() function Example

Admin   Laravel   179  2021-03-15 13:40:05

In this tutorial, I will show you how to use laravel str plural() function. In this example We will learn str plural() function in laravel application.

The Str::plural method converts a single word string to its plural form. This function currently only supports the English language:

Here I will give you simple and easy example for str plural() function in laravel application.

Example

 

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Controllers\FileController;

use Illuminate\Support\Str;

class HomeController extends Controller

{

/**

* Show the application dashboard.

*

* @return \Illuminate\Contracts\Support\Renderable

*/

public function index()

{

$plural1 = Str::plural('boy');

dd($plural1);

// output - boys

$plural2 = Str::plural('car');

dd($plural2);

// output - cars

$plural3 = Str::plural('child');

dd($plural3);

// output - children

}

}

Output :

 

"boys"

"cars"

"children"

It will help you...