Skip to content

Commit 4cf5d1f

Browse files
committed
2025-07-28までの原文変更点反映。
1 parent 3fad1a5 commit 4cf5d1f

22 files changed

+586
-28
lines changed

original-en/container.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,22 @@ $this->app->singletonIf(Transistor::class, function (Application $app) {
178178
});
179179
```
180180

181+
Alternatively, you may mark an interface or class with the `#[Singleton]` attribute to indicate to the container that it should be resolved one time:
182+
183+
```php
184+
<?php
185+
186+
namespace App\Services;
187+
188+
use Illuminate\Container\Attributes\Singleton;
189+
190+
#[Singleton]
191+
class Transistor
192+
{
193+
// ...
194+
}
195+
```
196+
181197
<a name="binding-scoped"></a>
182198
#### Binding Scoped Singletons
183199

@@ -201,6 +217,22 @@ $this->app->scopedIf(Transistor::class, function (Application $app) {
201217
});
202218
```
203219

220+
Alternatively, you may mark an interface or class with the `#[Scoped]` attribute to indicate to the container that it should be resolved one time within a given Laravel request / job lifecycle:
221+
222+
```php
223+
<?php
224+
225+
namespace App\Services;
226+
227+
use Illuminate\Container\Attributes\Scoped;
228+
229+
#[Scoped]
230+
class Transistor
231+
{
232+
// ...
233+
}
234+
```
235+
204236
<a name="binding-instances"></a>
205237
#### Binding Instances
206238

original-en/database-testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ $this->assertNotSoftDeleted($user);
254254
<a name="assert-model-exists"></a>
255255
#### assertModelExists
256256

257-
Assert that a given model exists in the database:
257+
Assert that a given model or collection of models exist in the database:
258258

259259
```php
260260
use App\Models\User;
@@ -267,7 +267,7 @@ $this->assertModelExists($user);
267267
<a name="assert-model-missing"></a>
268268
#### assertModelMissing
269269

270-
Assert that a given model does not exist in the database:
270+
Assert that a given model or collection of models do not exist in the database:
271271

272272
```php
273273
use App\Models\User;

original-en/errors.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,20 @@ class PodcastProcessingException extends Exception implements ShouldntReport
203203
}
204204
```
205205

206+
If you need even more control over when a particular type of exception is ignored, you may provide a closure to the `dontReportWhen` method:
207+
208+
```php
209+
use App\Exceptions\InvalidOrderException;
210+
use Throwable;
211+
212+
->withExceptions(function (Exceptions $exceptions) {
213+
$exceptions->dontReportWhen(function (Throwable $e) {
214+
return $e instanceof PodcastProcessingException &&
215+
$e->reason() === 'Subscription expired';
216+
});
217+
})
218+
```
219+
206220
Internally, Laravel already ignores some types of errors for you, such as exceptions resulting from 404 HTTP errors or 419 HTTP responses generated by invalid CSRF tokens. If you would like to instruct Laravel to stop ignoring a given type of exception, you may use the `stopIgnoring` exception method in your application's `bootstrap/app.php` file:
207221

208222
```php

original-en/events.md

Lines changed: 150 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
- [Queued Event Listeners](#queued-event-listeners)
1212
- [Manually Interacting With the Queue](#manually-interacting-with-the-queue)
1313
- [Queued Event Listeners and Database Transactions](#queued-event-listeners-and-database-transactions)
14+
- [Queued Listener Middleware](#queued-listener-middleware)
15+
- [Encrypted Queued Listeners](#encrypted-queued-listeners)
1416
- [Handling Failed Jobs](#handling-failed-jobs)
1517
- [Dispatching Events](#dispatching-events)
1618
- [Dispatching Events After Database Transactions](#dispatching-events-after-database-transactions)
@@ -455,6 +457,62 @@ class SendShipmentNotification implements ShouldQueueAfterCommit
455457
> [!NOTE]
456458
> To learn more about working around these issues, please review the documentation regarding [queued jobs and database transactions](/docs/{{version}}/queues#jobs-and-database-transactions).
457459
460+
<a name="queued-listener-middleware"></a>
461+
### Queued Listener Middleware
462+
463+
Queued listeners can also utilize [job middleware](/docs/{{version}}/queues#job-middleware). Job middleware allow you to wrap custom logic around the execution of queued listeners, reducing boilerplate in the listeners themselves. After creating job middleware, they may be attached to a listener by returning them from the listener's `middleware` method:
464+
465+
```php
466+
<?php
467+
468+
namespace App\Listeners;
469+
470+
use App\Events\OrderShipped;
471+
use App\Jobs\Middleware\RateLimited;
472+
use Illuminate\Contracts\Queue\ShouldQueue;
473+
474+
class SendShipmentNotification implements ShouldQueue
475+
{
476+
/**
477+
* Handle the event.
478+
*/
479+
public function handle(OrderShipped $event): void
480+
{
481+
// Process the event...
482+
}
483+
484+
/**
485+
* Get the middleware the listener should pass through.
486+
*
487+
* @return array<int, object>
488+
*/
489+
public function middleware(OrderShipped $event): array
490+
{
491+
return [new RateLimited];
492+
}
493+
}
494+
```
495+
496+
<a name="encrypted-queued-listeners"></a>
497+
#### Encrypted Queued Listeners
498+
499+
Laravel allows you to ensure the privacy and integrity of a queued listener's data via [encryption](/docs/{{version}}/encryption). To get started, simply add the `ShouldBeEncrypted` interface to the listener class. Once this interface has been added to the class, Laravel will automatically encrypt your listener before pushing it onto a queue:
500+
501+
```php
502+
<?php
503+
504+
namespace App\Listeners;
505+
506+
use App\Events\OrderShipped;
507+
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
508+
use Illuminate\Contracts\Queue\ShouldQueue;
509+
510+
class SendShipmentNotification implements ShouldQueue, ShouldBeEncrypted
511+
{
512+
// ...
513+
}
514+
```
515+
458516
<a name="handling-failed-jobs"></a>
459517
### Handling Failed Jobs
460518

@@ -540,7 +598,7 @@ If both `retryUntil` and `tries` are defined, Laravel gives precedence to the `r
540598
<a name="specifying-queued-listener-backoff"></a>
541599
#### Specifying Queued Listener Backoff
542600

543-
If you would like to configure how many seconds Laravel should wait before retrying a listener that has encountered an exception, you may do so by defining a `backoff` property on your listener class:
601+
If you would like to configure how many seconds Laravel should wait before retrying a listener that has encountered an exception, you may do so by defining a `$backoff` property on your listener class:
544602

545603
```php
546604
/**
@@ -557,7 +615,7 @@ If you require more complex logic for determining the listeners's backoff time,
557615
/**
558616
* Calculate the number of seconds to wait before retrying the queued listener.
559617
*/
560-
public function backoff(): int
618+
public function backoff(OrderShipped $event): int
561619
{
562620
return 3;
563621
}
@@ -571,12 +629,101 @@ You may easily configure "exponential" backoffs by returning an array of backoff
571629
*
572630
* @return list<int>
573631
*/
574-
public function backoff(): array
632+
public function backoff(OrderShipped $event): array
575633
{
576634
return [1, 5, 10];
577635
}
578636
```
579637

638+
<a name="specifying-queued-listener-max-exceptions"></a>
639+
#### Specifying Queued Listener Max Exceptions
640+
641+
Sometimes you may wish to specify that a queued listener may be attempted many times, but should fail if the retries are triggered by a given number of unhandled exceptions (as opposed to being released by the `release` method directly). To accomplish this, you may define a `$maxExceptions` property on your listener class:
642+
643+
```php
644+
<?php
645+
646+
namespace App\Listeners;
647+
648+
use App\Events\OrderShipped;
649+
use Illuminate\Contracts\Queue\ShouldQueue;
650+
use Illuminate\Queue\InteractsWithQueue;
651+
652+
class SendShipmentNotification implements ShouldQueue
653+
{
654+
use InteractsWithQueue;
655+
656+
/**
657+
* The number of times the queued listener may be attempted.
658+
*
659+
* @var int
660+
*/
661+
public $tries = 25;
662+
663+
/**
664+
* The maximum number of unhandled exceptions to allow before failing.
665+
*
666+
* @var int
667+
*/
668+
public $maxExceptions = 3;
669+
670+
/**
671+
* Handle the event.
672+
*/
673+
public function handle(OrderShipped $event): void
674+
{
675+
// Process the event...
676+
}
677+
}
678+
```
679+
680+
In this example, the listener will be retried up to 25 times. However, the listener will fail if three unhandled exceptions are thrown by the listener.
681+
682+
<a name="specifying-queued-listener-timeout"></a>
683+
#### Specifying Queued Listener Timeout
684+
685+
Often, you know roughly how long you expect your queued listeners to take. For this reason, Laravel allows you to specify a "timeout" value. If a listener is processing for longer than the number of seconds specified by the timeout value, the worker processing the listener will exit with an error. You may define the maximum number of seconds a listener should be allowed to run by defining a `$timeout` property on your listener class:
686+
687+
```php
688+
<?php
689+
690+
namespace App\Listeners;
691+
692+
use App\Events\OrderShipped;
693+
use Illuminate\Contracts\Queue\ShouldQueue;
694+
695+
class SendShipmentNotification implements ShouldQueue
696+
{
697+
/**
698+
* The number of seconds the listener can run before timing out.
699+
*
700+
* @var int
701+
*/
702+
public $timeout = 120;
703+
}
704+
```
705+
706+
If you would like to indicate that a listener should be marked as failed on timeout, you may define the `$failOnTimeout` property on the listener class:
707+
708+
```php
709+
<?php
710+
711+
namespace App\Listeners;
712+
713+
use App\Events\OrderShipped;
714+
use Illuminate\Contracts\Queue\ShouldQueue;
715+
716+
class SendShipmentNotification implements ShouldQueue
717+
{
718+
/**
719+
* Indicate if the listener should be marked as failed on timeout.
720+
*
721+
* @var bool
722+
*/
723+
public $failOnTimeout = true;
724+
}
725+
```
726+
580727
<a name="dispatching-events"></a>
581728
## Dispatching Events
582729

original-en/notifications.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
- [SMS Notifications](#sms-notifications)
3737
- [Prerequisites](#sms-prerequisites)
3838
- [Formatting SMS Notifications](#formatting-sms-notifications)
39-
- [Unicode Content](#unicode-content)
4039
- [Customizing the "From" Number](#customizing-the-from-number)
4140
- [Adding a Client Reference](#adding-a-client-reference)
4241
- [Routing SMS Notifications](#routing-sms-notifications)
@@ -695,7 +694,7 @@ public function toMail(object $notifiable): MailMessage
695694
}
696695
```
697696

698-
If your application is using the Mailgun driver, you may consult Mailgun's documentation for more information on [tags](https://documentation.mailgun.com/en/latest/user_manual.html#tagging-1) and [metadata](https://documentation.mailgun.com/en/latest/user_manual.html#attaching-data-to-messages). Likewise, the Postmark documentation may also be consulted for more information on their support for [tags](https://postmarkapp.com/blog/tags-support-for-smtp) and [metadata](https://postmarkapp.com/support/article/1125-custom-metadata-faq).
697+
If your application is using the Mailgun driver, you may consult Mailgun's documentation for more information on [tags](https://documentation.mailgun.com/docs/mailgun/user-manual/tracking-messages/#tags) and [metadata](https://documentation.mailgun.com/docs/mailgun/user-manual/sending-messages/#attaching-metadata-to-messages). Likewise, the Postmark documentation may also be consulted for more information on their support for [tags](https://postmarkapp.com/blog/tags-support-for-smtp) and [metadata](https://postmarkapp.com/support/article/1125-custom-metadata-faq).
699698

700699
If your application is using Amazon SES to send emails, you should use the `metadata` method to attach [SES "tags"](https://docs.aws.amazon.com/ses/latest/APIReference/API_MessageTag.html) to the message.
701700

@@ -992,6 +991,16 @@ foreach ($user->unreadNotifications as $notification) {
992991
}
993992
```
994993

994+
If you want to retrieve only the "read" notifications, you may use the `readNotifications` relationship:
995+
996+
```php
997+
$user = App\Models\User::find(1);
998+
999+
foreach ($user->readNotifications as $notification) {
1000+
echo $notification->type;
1001+
}
1002+
```
1003+
9951004
> [!NOTE]
9961005
> To access your notifications from your JavaScript client, you should define a notification controller for your application which returns the notifications for a notifiable entity, such as the current user. You may then make an HTTP request to that controller's URL from your JavaScript client.
9971006
@@ -1361,7 +1370,6 @@ If a notification supports being sent as a Slack message, you should define a `t
13611370
```php
13621371
use Illuminate\Notifications\Slack\BlockKit\Blocks\ContextBlock;
13631372
use Illuminate\Notifications\Slack\BlockKit\Blocks\SectionBlock;
1364-
use Illuminate\Notifications\Slack\BlockKit\Composites\ConfirmObject;
13651373
use Illuminate\Notifications\Slack\SlackMessage;
13661374

13671375
/**
@@ -1604,7 +1612,7 @@ Notification::locale('es')->send(
16041612
```
16051613

16061614
<a name="user-preferred-locales"></a>
1607-
### User Preferred Locales
1615+
#### User Preferred Locales
16081616

16091617
Sometimes, applications store each user's preferred locale. By implementing the `HasLocalePreference` contract on your notifiable model, you may instruct Laravel to use this stored locale when sending a notification:
16101618

original-en/packages.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
- [Service Providers](#service-providers)
77
- [Resources](#resources)
88
- [Configuration](#configuration)
9-
- [Migrations](#migrations)
109
- [Routes](#routes)
10+
- [Migrations](#migrations)
1111
- [Language Files](#language-files)
1212
- [Views](#views)
1313
- [View Components](#view-components)
@@ -123,7 +123,7 @@ The `mergeConfigFrom` method accepts the path to your package's configuration fi
123123

124124
```php
125125
/**
126-
* Register any application services.
126+
* Register any package services.
127127
*/
128128
public function register(): void
129129
{

0 commit comments

Comments
 (0)