修改理由:

abort函数翻译没对

相关信息:


此投稿由 MArtian 1年前 合并。

标题修改:

+ 辅助函数

内容修改:

红色背景 为原始内容

绿色背景 为新增或者修改的内容

OldNewDifferences
1  
21# 辅助函数
32
43- [简介](#introduction)
 
9594
9695</div>
9796
98 
99 
 97
 98
10099<a name="strings-method-list"></a>
101100### 字符串
102101
 
269268
270269</div>
271270
272 
273 
 271
 272
274273<a name="urls-method-list"></a>
275274### URLs
276275
 
402401   // ['name' => 'Desk', 'price' => 100]
403402
404403
405 
406 
 404
 405
407406<a name="method-array-collapse"></a>
408407#### `Arr::collapse()` {.collection-method}
409408
 
505504   // false
506505
507506<a name="method-array-first"></a>
508 
509 
 507
 508
510509#### `Arr::first()` {.collection-method}
511510
512511`Arr::first` 函数返回数组中满足指定条件的第一个元素:
 
591590
592591   // false
593592
594 
595 
 593
 594
596595<a name="method-array-hasany"></a>
597596#### `Arr::hasAny()` {.collection-method}
598597
 
682681       ]
683682   */
684683
685 
686 
 684
 685
687686<a name="method-array-last"></a>
688687#### `Arr::last()` {.collection-method}
689688
 
758757   // [1 => 'Taylor', 2 => 'Abigail']
759758
760759<a name="method-array-prepend"></a>
761 
762 
 760
 761
763762<a name="method-array-last"></a>
764763#### `Arr::last()` {.collection-method}
765764
 
834833   // [1 => 'Taylor', 2 => 'Abigail']
835834
836835<a name="method-array-prepend"></a>
837 
838 
 836
 837
839838#### `Arr::prepend()` {.collection-method}
840839
841840`Arr::prepend` 函数将一个值插入到数组的开始位置:
 
940939
941940   // [2, 5] - (retrieved randomly)
942941
943 
944 
 942
 943
945944<a name="method-array-set"></a>
946945#### `Arr::set()` {.collection-method}
947946
 
10591058       ]
10601059   */
10611060
1062 
1063 
 1061
 1062
10641063<a name="method-array-to-css-classes"></a>
10651064#### `Arr::toCssClasses()` {.collection-method}
10661065
 
11381137
11391138   // ['Laravel']
11401139
1141 
1142 
 1140
 1141
11431142如果给定值是 `null` ,将返回一个空数组:
11441143
11451144   use Illuminate\Support\Arr;
 
12421241       ]
12431242   */
12441243
1245 
1246 
 1244
 1245
12471246通常情况下,已存在的值将会被覆盖。如果只是希望设置一个目前不存在的值,你可以增加一个 `false` 作为函数的第四个参数:
12481247
12491248   $data = ['products' => ['desk' => ['price' => 100]]];
 
13051304   $path = config_path('app.php');
13061305
13071306<a name="method-database-path"></a>
1308 
1309 
 1307
 1308
13101309#### `database_path()` {.collection-method}
13111310
13121311`database_path` 函数返回 `database` 目录的完整路径。你可以使用 `database_path` 函数来生成数据库目录下指定文件的完整路径:
 
13521351
13531352   $path = resource_path('sass/app.scss');
13541353
1355 
1356 
 1354
 1355
13571356<a name="method-storage-path"></a>
13581357#### `storage_path()`
13591358
 
14171416
14181417   // ' my name'
14191418
1420 
1421 
 1419
 1420
14221421<a name="method-str-after-last"></a>
14231422#### `Str::afterLast()`
14241423
 
14961495
14971496   // fooBar
14981497
1499 
1500 
 1498
 1499
15011500<a name="method-str-contains"></a>
15021501#### `Str::contains()`
15031502
 
15661565
15671566`radius` 选项默认为 `100`,允许你定义应出现在截断字符串前后的字符数。
15681567
1569 
1570 
 1568
 1569
15711570此外,你可以使用`omission`选项来定义将附加到截断字符串的字符串:
15721571
15731572   use Illuminate\Support\Str;
 
16501649
16511650   // false
16521651
1653 
1654 
 1652
 1653
16551654<a name="method-str-is-json"></a>
16561655#### `Str::isJson()` {.collection-method}
16571656
 
17451744
17461745   // 敏捷的棕色狐狸...
17471746
1748 
1749 
 1747
 1748
17501749你也可通过第三个参数来改变追加到末尾的字符串:
17511750
17521751   use Illuminate\Support\Str;
 
18091808
18101809   return (string) Str::orderedUuid();
18111810
1812 
1813 
 1811
 1812
18141813<a name="method-str-padboth"></a>
18151814#### `Str::padBoth()` {.collection-method}
18161815
 
18861885
18871886   // children
18881887
1889 
1890 
 1888
 1889
18911890你可以提供一个整数作为函数的第二个参数来检索字符串的单数或复数形式:
18921891
18931892   use Illuminate\Support\Str;
 
19641963
19651964   // Laravel 9.x
19661965
1967 
1968 
 1966
 1967
19691968<a name="method-str-replace-array"></a>
19701969#### `Str::replaceArray()` {.collection-method}
19711970
 
20392038
20402039   // laravel-5-framework
20412040
2042 
2043 
 2041
 2042
20442043<a name="method-snake-case"></a>
20452044#### `Str::snake()` {.collection-method}
20462045
 
21212120
21222121   // Laravel
21232122
2124 
2125 
 2123
 2124
21262125<a name="method-str-substrcount"></a>
21272126#### `Str::substrCount()` {.collection-method}
21282127
 
21922191
21932192   // Foo bar
21942193
2195 
2196 
 2194
 2195
21972196<a name="method-str-ucsplit"></a>
21982197#### `Str::ucsplit()` {.collection-method}
21992198
 
22732272
22742273   // 'foo_bar'
22752274
2276 
2277 
 2275
 2276
22782277<a name="method-trans"></a>
22792278#### `trans()` {.collection-method}
22802279
 
23202319
23212320   // 'Controller'
23222321
2323 
2324 
 2322
 2323
23252324<a name="method-fluent-str-append"></a>
23262325#### `append` {.collection-method}
23272326
 
24072406
24082407   // 'a'
24092408
2410 
2411 
 2409
 2410
24122411<a name="method-fluent-str-camel"></a>
24132412#### `camel` {.collection-method}
24142413
 
24932492
24942493   // '...is my na...'
24952494
2496 
2497 
 2495
 2496
24982497`radius` 选项默认为 `100`,允许你定义应出现在截断字符串每一侧的字符数。
24992498
25002499此外,还可以使用 `omission` 选项更改将添加到截断字符串之前和附加的字符串
 
25672566
25682567   // this/string/
25692568
2570 
2571 
 2569
 2570
25722571<a name="method-fluent-str-headline"></a>
25732572#### `headline` {.collection-method}
25742573
 
26552654
26562655   // true
26572656
2658 
2659 
 2657
 2658
26602659<a name="method-fluent-str-is-json"></a>
26612660#### `isJson` {.collection-method}
26622661
 
27512750
27522751   // The quick brown fox...
27532752
2754 
2755 
 2753
 2754
27562755你也可以通过第二个参数来改变追加到末尾的字符串:
27572756
27582757   use Illuminate\Support\Str;
 
28252824
28262825   // tayl**********.com
28272826
2828 
2829 
 2827
 2828
28302829<a name="method-fluent-str-match"></a>
28312830#### `match`
28322831
 
29052904
29062905   // ' James  '
29072906
2908 
2909 
 2907
 2908
29102909<a name="method-fluent-str-padleft"></a>
29112910#### `padLeft`
29122911
 
29832982
29842983   // child
29852984
2986 
2987 
 2985
 2986
29882987<a name="method-fluent-str-prepend"></a>
29892988#### `prepend`
29902989
 
30553054
30563055   // the quick brown fox jumps over a lazy dog
30573056
3058 
3059 
 3057
 3058
30603059<a name="method-fluent-str-replace-matches"></a>
30613060#### `replaceMatches`
30623061
 
31203119
31213120   // child
31223121
3123 
3124 
 3122
 3123
31253124<a name="method-fluent-str-slug"></a>
31263125#### `slug` {.collection-method}
31273126
 
32033202
32043203   // FooBar
32053204
3206 
3207 
 3205
 3206
32083207<a name="method-fluent-str-substr"></a>
32093208#### `substr` {.collection-method}
32103209
 
32683267   // LARAVEL FRAMEWORK
32693268
32703269<a name="method-fluent-str-test"></a>
3271 
3272 
 3270
 3271
32733272#### `test` {.collection-method}
32743273
32753274`test` 方法确定字符串是否与给定的正则表达式模式匹配:
 
33553354   // 'Taylor Otwell'
33563355如果需要,可以将另一个闭包作为第三个参数传递给 `when` 方法。如果条件参数的计算结果为 `false`,则将执行此闭包。
33573356
3358 
3359 
 3357
 3358
33603359<a name="method-fluent-str-when-contains"></a>
33613360#### `whenContains` {.collection-method}
33623361
 
34163415
34173416   // 'Laravel'
34183417
3419 
3420 
 3418
 3419
34213420<a name="method-fluent-str-when-not-empty"></a>
34223421#### `whenNotEmpty` {.collection-method}
34233422
 
34883487
34893488   // 'Framework'
34903489
3491 
3492 
 3490
 3491
34933492<a name="method-fluent-str-when-is"></a>
34943493#### `whenIs` {.collection-method}
34953494
 
35593558
35603559   // 'Laravel Framework'
35613560
3562 
3563 
 3561
 3562
35643563<a name="method-fluent-str-word-count"></a>
35653564#### `wordCount` {.collection-method}
35663565
 
36233622
36243623   $url = route('route.name', ['id' => 1]);
36253624
3626 
3627 
 3625
 3626
36283627默认情况下,`route` 函数会生成一个绝对路径的 URL。 如果想生成一个相对路径 URL,你可以传递 `false` 作为函数的第三个参数:
36293628
36303629   $url = route('route.name', ['id' => 1], false);
 
36743673   $previous = url()->previous();
36753674
36763675<a name="miscellaneous"></a>
3677 ## Miscellaneous
 3676## 杂项
36783677
36793678<a name="method-abort"></a>
36803679#### `abort()` {.collection-method}
36813680
3682 `abort` 函数抛出 [HTTP 异常](/docs/laravel/10.x/errors#http-exceptions),它将由 [异常处理程序](/docs/laravel/10.x/errors#the-exception-handler):
 3681使用`abort` 函数抛出一个[HTTP 异常](/docs/laravel/10.x/errors#http-exceptions)交给[异常处理](/docs/laravel/10.x/errors#the-exception-handler "异常处理程序")
36833682
36843683   abort(403);
36853684
3686 
3687 
 3685
 3686
36883687你还可以提供应发送到浏览器的异常消息和自定义 HTTP 响应标头:
36893688
36903689   abort(403, 'Unauthorized.', $headers);
 
37383737
37393738   return back();
37403739
3741 
3742 
 3740
 3741
37433742<a name="method-bcrypt"></a>
37443743#### `bcrypt()` {.collection-method}
37453744
 
38053804
38063805   $collection = collect(['taylor', 'abigail']);
38073806
3808 
3809 
 3807
 3808
38103809<a name="method-config"></a>
38113810#### `config()` {.collection-method}
38123811
 
38583857   dd($value1, $value2, $value3, ...);
38593858
38603859如果你不想停止脚本的执行,请改用 [`dump`](#method-dump) 函数。
3861 
3862 
 3860
 3861
38633862<a name="method-dispatch"></a>
38643863#### `dispatch()` {.collection-method}
38653864
 
39213920@endfor
39223921```
39233922
3924 
3925 
 3923
 3924
39263925默认情况下,`fake` 函数将使用 `config/app.php` 配置文件中的 `app.faker_locale` 配置选项; 但是,你也可以通过将语言环境传递给 `fake` 函数来指定语言环境。 每个语言环境将解析一个单独的单例:
39273926
39283927   fake('nl_NL')->name()
 
39833982   </form>
39843983
39853984<a name="method-now"></a>
3986 
3987 
 3985
 3986
39883987#### `now()` {.collection-method}
39893988
39903989`now` 函数为当前时间创建一个新的 `Illuminate\Support\Carbon` 实例:
 
40334032<a name="method-redirect"></a>
40344033#### `redirect()` {.collection-method}
40354034
4036 
4037 
 4035
 4036
40384037`redirect` 函数返回一个[重定向 HTTP 响应](/docs/laravel/10.x/responses#redirects),或者如果不带参数调用则返回重定向器实例:
40394038
40404039   return redirect($to = null, $status = 302, $headers = [], $https = null);
 
40904089       return $this->method();
40914090   });
40924091
4093 
4094 
 4092
 4093
40954094你还可以将第二个参数传递给「rescue」函数。 如果在执行闭包时发生异常,这个参数将是应该返回的「默认」值:
40964095
40974096   return rescue(function () {
 
41454144       // Sleep for 100ms on first retry, 200ms on second retry...
41464145   });
41474146
4148 
4149 
 4147
 4148
41504149要仅在特定条件下重试,您可以将闭包作为第四个参数传递给 `retry` 函数:
41514150
41524151   use Exception;
 
41984197       // ...
41994198   });
42004199
4201 
4202 
 4200
 4201
42034202<a name="method-throw-if"></a>
42044203#### `throw_if()` {.collection-method}
42054204
 
42664265
42674266   $validator = validator($data, $rules, $messages);
42684267
4269 
4270 
 4268
 4269
42714270<a name="method-value"></a>
42724271#### `value()` {.collection-method}
42734272
 
43404339   ]);
43414340
43424341默认情况下,给定的回调将执行一次(一次迭代),并且它们的持续时间将显示在浏览器/控制台中。
4343 
4344 
 4342
 4343
43454344要多次调用回调,你可以将回调应调用的迭代次数指定为方法的第二个参数。 当多次执行回调时,「基准」类将返回在所有迭代中执行回调所花费的平均毫秒数:
43464345
43474346   Benchmark::dd(fn () => User::count(), iterations: 10); // 0.5 ms
 
43884387           ->then(fn (User $user) => $user);
43894388```
43904389
4391 
4392 
 4390
 4391
43934392<a name="lottery"></a>
43944393### Lottery
43954394
 
44294428
44304429   // Lottery will return to normal behavior...
44314430   Lottery::determineResultsNormally();
 4431  
44324432
4433