Skip to content

Commit 86f994f

Browse files
committed
2025-09-01までの原文変更点反映。
1 parent d8beb05 commit 86f994f

17 files changed

+151
-23
lines changed

original-en/collections.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ For the majority of the remaining collection documentation, we'll discuss each m
230230
[times](#method-times)
231231
[toArray](#method-toarray)
232232
[toJson](#method-tojson)
233+
[toPrettyJson](#method-to-pretty-json)
233234
[transform](#method-transform)
234235
[undot](#method-undot)
235236
[union](#method-union)
@@ -3333,6 +3334,17 @@ $collection->toJson();
33333334
// '{"name":"Desk", "price":200}'
33343335
```
33353336

3337+
<a name="method-to-pretty-json"></a>
3338+
#### `toPrettyJson()` {.collection-method}
3339+
3340+
The `toPrettyJson` method converts the collection into a formatted JSON string using the `JSON_PRETTY_PRINT` option:
3341+
3342+
```php
3343+
$collection = collect(['name' => 'Desk', 'price' => 200]);
3344+
3345+
$collection->toPrettyJson();
3346+
```
3347+
33363348
<a name="method-transform"></a>
33373349
#### `transform()` {.collection-method}
33383350

@@ -4316,3 +4328,29 @@ $users->take(5)->all();
43164328
// The rest are hydrated from the database...
43174329
$users->take(20)->all();
43184330
```
4331+
4332+
<a name="method-with-heartbeat"></a>
4333+
#### `withHeartbeat()` {.collection-method}
4334+
4335+
The `withHeartbeat` method allows you to execute a callback at regular time intervals while a lazy collection is being enumerated. This is particularly useful for long-running operations that require periodic maintenance tasks, such as extending locks or sending progress updates:
4336+
4337+
```php
4338+
use Carbon\CarbonInterval;
4339+
use Illuminate\Support\Facades\Cache;
4340+
4341+
$lock = Cache::lock('generate-reports', seconds: 60 * 5);
4342+
4343+
if ($lock->get()) {
4344+
try {
4345+
Report::where('status', 'pending')
4346+
->lazy()
4347+
->withHeartbeat(
4348+
CarbonInterval::minutes(4),
4349+
fn () => $lock->extend(CarbonInterval::minutes(5))
4350+
)
4351+
->each(fn ($report) => $report->process());
4352+
} finally {
4353+
$lock->release();
4354+
}
4355+
}
4356+
```

original-en/dusk.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2392,7 +2392,7 @@ $browser->visit(new Dashboard)
23922392
<a name="components"></a>
23932393
## Components
23942394

2395-
Components are similar to Dusks “page objects”, but are intended for pieces of UI and functionality that are re-used throughout your application, such as a navigation bar or notification window. As such, components are not bound to specific URLs.
2395+
Components are similar to Dusk's “page objects”, but are intended for pieces of UI and functionality that are re-used throughout your application, such as a navigation bar or notification window. As such, components are not bound to specific URLs.
23962396

23972397
<a name="generating-components"></a>
23982398
### Generating Components

original-en/eloquent-relationships.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2127,7 +2127,7 @@ Sometimes you may wish to eager load a relationship but also specify additional
21272127

21282128
```php
21292129
use App\Models\User;
2130-
use Illuminate\Contracts\Database\Eloquent\Builder;
2130+
use Illuminate\Database\Eloquent\Builder;
21312131

21322132
$users = User::with(['posts' => function (Builder $query) {
21332133
$query->where('title', 'like', '%code%');

original-en/helpers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ $array = [];
972972

973973
Arr::push($array, 'office.furniture', 'Desk');
974974

975-
// $array: ['office' => ['furniture' => 'Desk']]
975+
// $array: ['office' => ['furniture' => ['Desk']]]
976976
```
977977

978978
<a name="method-array-query"></a>
@@ -3241,7 +3241,7 @@ defer(fn () => Metrics::reportOrder($order))->always();
32413241
```
32423242

32433243
> [!WARNING]
3244-
> If you have the **swoole** PHP extension installed, Laravel's `defer` function may conflict with Swoole's own global `defer` function, leading to web server errors. Make sure you call Laravel's `defer` helper by explicitly namespacing it: `use function Illuminate\Support\defer;`
3244+
> If you have the [Swoole PHP extension](https://www.php.net/manual/en/book.swoole.php) installed, Laravel's `defer` function may conflict with Swoole's own global `defer` function, leading to web server errors. Make sure you call Laravel's `defer` helper by explicitly namespacing it: `use function Illuminate\Support\defer;`
32453245
32463246
<a name="cancelling-deferred-functions"></a>
32473247
#### Cancelling Deferred Functions

original-en/horizon.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ You can define the maximum number of attempts a job can consume within a supervi
179179
180180
Adjusting the `tries` option is essential when using middlewares such as `WithoutOverlapping` or `RateLimited` because they consume attempts. To handle this, adjust the `tries` configuration value either at the supervisor level or by defining the `$tries` property on the job class.
181181

182-
If you dont set the `tries` option, Horizon defaults to a single attempt, unless the job class defines `$tries`, which takes precedence over the Horizon configuration.
182+
If you don't set the `tries` option, Horizon defaults to a single attempt, unless the job class defines `$tries`, which takes precedence over the Horizon configuration.
183183

184184
Setting `tries` or `$tries` to 0 allows unlimited attempts, which is ideal when the number of attempts is uncertain. To prevent endless failures, you can limit the number of exceptions allowed by setting the `$maxExceptions` property on the job class.
185185

@@ -396,7 +396,7 @@ With this configuration, Horizon will assign 10 processes to the `default` queue
396396
<a name="no-balancing"></a>
397397
### No Balancing
398398

399-
When the `balance` option is set to `false`, Horizon processes queues strictly in the order they're listed, similar to Laravels default queue system. However, it will still scale the number of worker processes if jobs begin to accumulate:
399+
When the `balance` option is set to `false`, Horizon processes queues strictly in the order they're listed, similar to Laravel's default queue system. However, it will still scale the number of worker processes if jobs begin to accumulate:
400400

401401
```php
402402
'environments' => [

original-en/http-client.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,24 @@ Http::get('https://github.com/laravel/framework');
823823
Http::get('https://laravel.com');
824824
```
825825

826+
Sometimes, you may wish to prevent most stray requests while still allowing specific requests to execute. To accomplish this, you may pass an array of URL patterns to the `allowStrayRequests` method. Any request matching one of the given patterns will be allowed, while all other requests will continue to throw an exception:
827+
828+
```php
829+
use Illuminate\Support\Facades\Http;
830+
831+
Http::preventStrayRequests();
832+
833+
Http::allowStrayRequests([
834+
'http://127.0.0.1:5000/*',
835+
]);
836+
837+
// This request is executed...
838+
Http::get('http://127.0.0.1:5000/generate');
839+
840+
// An exception is thrown...
841+
Http::get('https://laravel.com');
842+
```
843+
826844
<a name="events"></a>
827845
## Events
828846

original-en/pagination.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ $users = User::where('votes', '>', 100)->paginate(
123123

124124
While `paginate` and `simplePaginate` create queries using the SQL "offset" clause, cursor pagination works by constructing "where" clauses that compare the values of the ordered columns contained in the query, providing the most efficient database performance available amongst all of Laravel's pagination methods. This method of pagination is particularly well-suited for large data-sets and "infinite" scrolling user interfaces.
125125

126-
Unlike offset based pagination, which includes a page number in the query string of the URLs generated by the paginator, cursor based pagination places a "cursor" string in the query string. The cursor is an encoded string containing the location that the next paginated query should start paginating and the direction that it should paginate:
126+
Unlike offset based pagination, which includes a page number in the query string of the URLs generated by the paginator, cursor-based pagination places a "cursor" string in the query string. The cursor is an encoded string containing the location that the next paginated query should start paginating and the direction that it should paginate:
127127

128128
```text
129129
http://localhost/users?cursor=eyJpZCI6MTUsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0
130130
```
131131

132-
You may create a cursor based paginator instance via the `cursorPaginate` method offered by the query builder. This method returns an instance of `Illuminate\Pagination\CursorPaginator`:
132+
You may create a cursor-based paginator instance via the `cursorPaginate` method offered by the query builder. This method returns an instance of `Illuminate\Pagination\CursorPaginator`:
133133

134134
```php
135135
$users = DB::table('users')->orderBy('id')->cursorPaginate(15);

original-en/queues.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ While building your web application, you may have some tasks, such as parsing an
6262

6363
Laravel queues provide a unified queueing API across a variety of different queue backends, such as [Amazon SQS](https://aws.amazon.com/sqs/), [Redis](https://redis.io), or even a relational database.
6464

65-
Laravel's queue configuration options are stored in your application's `config/queue.php` configuration file. In this file, you will find connection configurations for each of the queue drivers that are included with the framework, including the database, [Amazon SQS](https://aws.amazon.com/sqs/), [Redis](https://redis.io), and [Beanstalkd](https://beanstalkd.github.io/) drivers, as well as a synchronous driver that will execute jobs immediately (for use during local development). A `null` queue driver is also included which discards queued jobs.
65+
Laravel's queue configuration options are stored in your application's `config/queue.php` configuration file. In this file, you will find connection configurations for each of the queue drivers that are included with the framework, including the database, [Amazon SQS](https://aws.amazon.com/sqs/), [Redis](https://redis.io), and [Beanstalkd](https://beanstalkd.github.io/) drivers, as well as a synchronous driver that will execute jobs immediately (for use during development or testing). A `null` queue driver is also included which discards queued jobs.
6666

6767
> [!NOTE]
6868
> Laravel Horizon is a beautiful dashboard and configuration system for your Redis powered queues. Check out the full [Horizon documentation](/docs/{{version}}/horizon) for more information.
@@ -1945,7 +1945,9 @@ If you defined your DynamoDB table with a `ttl` attribute, you may define config
19451945
Instead of dispatching a job class to the queue, you may also dispatch a closure. This is great for quick, simple tasks that need to be executed outside of the current request cycle. When dispatching closures to the queue, the closure's code content is cryptographically signed so that it cannot be modified in transit:
19461946

19471947
```php
1948-
$podcast = App\Podcast::find(1);
1948+
use App\Models\Podcast;
1949+
1950+
$podcast = Podcast::find(1);
19491951

19501952
dispatch(function () use ($podcast) {
19511953
$podcast->publish();
@@ -2366,6 +2368,12 @@ To delete all of your failed jobs from the `failed_jobs` table, you may use the
23662368
php artisan queue:flush
23672369
```
23682370

2371+
The `queue:flush` command removes all failed job records from your queue, no matter how old the failed job is. You may use the `--hours` option to only delete jobs that failed a certain number of hours ago or earlier:
2372+
2373+
```shell
2374+
php artisan queue:flush --hours=48
2375+
```
2376+
23692377
<a name="ignoring-missing-models"></a>
23702378
### Ignoring Missing Models
23712379

@@ -2758,7 +2766,7 @@ Bus::fake();
27582766
// ...
27592767

27602768
Bus::assertBatched(function (PendingBatch $batch) {
2761-
return $batch->name == 'import-csv' &&
2769+
return $batch->name == 'Import CSV' &&
27622770
$batch->jobs->count() === 10;
27632771
});
27642772
```
@@ -2794,7 +2802,7 @@ $this->assertEmpty($batch->added);
27942802

27952803
Sometimes, you may need to test that a queued job [releases itself back onto the queue](#manually-releasing-a-job). Or, you may need to test that the job deleted itself. You may test these queue interactions by instantiating the job and invoking the `withFakeQueueInteractions` method.
27962804

2797-
Once the job's queue interactions have been faked, you may invoke the `handle` method on the job. After invoking the job, the `assertReleased`, `assertDeleted`, `assertNotDeleted`, `assertFailed`, `assertFailedWith`, and `assertNotFailed` methods may be used to make assertions against the job's queue interactions:
2805+
Once the job's queue interactions have been faked, you may invoke the `handle` method on the job. After invoking the job, various assertion methods are available to verify the job's queue interactions:
27982806

27992807
```php
28002808
use App\Exceptions\CorruptedAudioException;

original-en/redis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<a name="introduction"></a>
1414
## Introduction
1515

16-
[Redis](https://redis.io) is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain [strings](https://redis.io/docs/data-types/strings/), [hashes](https://redis.io/docs/data-types/hashes/), [lists](https://redis.io/docs/data-types/lists/), [sets](https://redis.io/docs/data-types/sets/), and [sorted sets](https://redis.io/docs/data-types/sorted-sets/).
16+
[Redis](https://redis.io) is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain [strings](https://redis.io/docs/latest/develop/data-types/strings/), [hashes](https://redis.io/docs/latest/develop/data-types/hashes/), [lists](https://redis.io/docs/latest/develop/data-types/lists/), [sets](https://redis.io/docs/latest/develop/data-types/sets/), and [sorted sets](https://redis.io/docs/latest/develop/data-types/sorted-sets/).
1717

1818
Before using Redis with Laravel, we encourage you to install and use the [PhpRedis](https://github.com/phpredis/phpredis) PHP extension via PECL. The extension is more complex to install compared to "user-land" PHP packages but may yield better performance for applications that make heavy use of Redis. If you are using [Laravel Sail](/docs/{{version}}/sail), this extension is already installed in your application's Docker container.
1919

original-en/reverb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<a name="introduction"></a>
2323
## Introduction
2424

25-
[Laravel Reverb](https://github.com/laravel/reverb) brings blazing-fast and scalable real-time WebSocket communication directly to your Laravel application, and provides seamless integration with Laravels existing suite of [event broadcasting tools](/docs/{{version}}/broadcasting).
25+
[Laravel Reverb](https://github.com/laravel/reverb) brings blazing-fast and scalable real-time WebSocket communication directly to your Laravel application, and provides seamless integration with Laravel's existing suite of [event broadcasting tools](/docs/{{version}}/broadcasting).
2626

2727
<a name="installation"></a>
2828
## Installation

0 commit comments

Comments
 (0)