Laravel 8 plural {#collection-method}
2021-07-19 10:33 更新
plural 方法将单数形式的字符串转换为复数形式。目前该函数仅支持英语:
use Illuminate\Support\Str;
$plural = Str::of('car')->plural();
// cars
$plural = Str::of('child')->plural();
// children 您亦可给该函数提供一个整数作为第二个参数用于检索单数或复数形式:
use Illuminate\Support\Str;
$plural = Str::of('child')->plural(2);
// children
$plural = Str::of('child')->plural(1);
// child 以上内容是否对您有帮助:

免费 AI IDE


更多建议: