You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: helpers.md
+86-1Lines changed: 86 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -94,6 +94,10 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
94
94
[Number::currency](#method-number-currency)
95
95
[Number::fileSize](#method-number-file-size)
96
96
[Number::forHumans](#method-number-for-humans)
97
+
[Number::ordinal](#method-number-ordinal)
98
+
[Number::spell](#method-number-spell)
99
+
[Number::useLocale](#method-number-use-locale)
100
+
[Number::withLocale](#method-number-with-locale)
97
101
98
102
</div>
99
103
@@ -1220,6 +1224,87 @@ The `Number::forHumans` method returns the human-readable format of the provided
1220
1224
1221
1225
// 1.23 million
1222
1226
1227
+
<aname="method-number-ordinal"></a>
1228
+
#### `Number::ordinal()` {.collection-method}
1229
+
1230
+
The `Number::ordinal` method returns a number's ordinal representation:
1231
+
1232
+
use Illuminate\Support\Number;
1233
+
1234
+
$number = Number::ordinal(1);
1235
+
1236
+
// 1st
1237
+
1238
+
$number = Number::ordinal(2);
1239
+
1240
+
// 2nd
1241
+
1242
+
$number = Number::ordinal(21);
1243
+
1244
+
// 21st
1245
+
1246
+
<aname="method-number-spell"></a>
1247
+
#### `Number::spell()` {.collection-method}
1248
+
1249
+
The `Number::spell` method transforms the given number into a string of words:
1250
+
1251
+
use Illuminate\Support\Number;
1252
+
1253
+
$number = Number::spell(102);
1254
+
1255
+
// one hundred and two
1256
+
1257
+
$number = Number::spell(88, locale: 'fr');
1258
+
1259
+
// quatre-vingt-huit
1260
+
1261
+
1262
+
The `after` argument allows you to specify a value after which all numbers should be spelled out:
1263
+
1264
+
$number = Number::spell(10, after: 10);
1265
+
1266
+
// 10
1267
+
1268
+
$number = Number::spell(11, after: 10);
1269
+
1270
+
// eleven
1271
+
1272
+
The `until` argument allows you to specify a value before which all numbers should be spelled out:
1273
+
1274
+
$number = Number::spell(5, until: 10);
1275
+
1276
+
// five
1277
+
1278
+
$number = Number::spell(10, until: 10);
1279
+
1280
+
// 10
1281
+
1282
+
<aname="method-number-use-locale"></a>
1283
+
#### `Number::useLocale()` {.collection-method}
1284
+
1285
+
The `Number::useLocale` method sets the default number locale globally, which affects how numbers and currency are formatted by subsequent invocations to the `Number` class's methods:
1286
+
1287
+
use Illuminate\Support\Number;
1288
+
1289
+
/**
1290
+
* Bootstrap any application services.
1291
+
*/
1292
+
public function boot(): void
1293
+
{
1294
+
Number::useLocale('de');
1295
+
}
1296
+
1297
+
<aname="method-number-with-locale"></a>
1298
+
#### `Number::withLocale()` {.collection-method}
1299
+
1300
+
The `Number::withLocale` method executes the given closure using the specified locale and then restores the original locale after the callback has executed:
1301
+
1302
+
use Illuminate\Support\Number;
1303
+
1304
+
$number = Number::withLocale('de', function () {
1305
+
return Number::format(1500);
1306
+
});
1307
+
1223
1308
<aname="paths"></a>
1224
1309
## Paths
1225
1310
@@ -1996,7 +2081,7 @@ The `value` function returns the value it is given. However, if you pass a closu
1996
2081
});
1997
2082
1998
2083
// false
1999
-
2084
+
2000
2085
Additional arguments may be passed to the `value` function. If the first argument is a closure then the additional parameters will be passed to the closure as arguments, otherwise they will be ignored:
Copy file name to clipboardExpand all lines: upgrade.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@
40
40
<aname="estimated-upgrade-time-??-minutes"></a>
41
41
#### Estimated Upgrade Time: ?? Minutes
42
42
43
-
> [!NOTE]
43
+
> [!NOTE]
44
44
> We attempt to document every possible breaking change. Since some of these breaking changes are in obscure parts of the framework only a portion of these changes may actually affect your application. Want to save time? You can use [Laravel Shift](https://laravelshift.com/) to help automate your application upgrades.
0 commit comments