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: configuration.md
+4-6
Original file line number
Diff line number
Diff line change
@@ -322,13 +322,11 @@ When accessing this hidden route, you will then be redirected to the `/` route o
322
322
323
323
By default, Laravel determines if your application is in maintenance mode using a file-based system. This means to activate maintenance mode, the `php artisan down` command has to be executed on each server hosting your application.
324
324
325
-
Alternatively, Laravel offers a cache-based method for handling maintenance mode. This method requires running the `php artisan down` command on just one server. To use this approach, modify the "driver" setting in the `config/app.php` file of your application to `cache`. Then, select a cache `store` that is accessible by all your servers. This ensures the maintenance mode status is consistently maintained across every server:
325
+
Alternatively, Laravel offers a cache-based method for handling maintenance mode. This method requires running the `php artisan down` command on just one server. To use this approach, modify the maintenance mode variables in your application's `.env` file. You should select a cache `store` that is accessible by all of your servers. This ensures the maintenance mode status is consistently maintained across every server:
Copy file name to clipboardexpand all lines: errors.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ During local development, you should set the `APP_DEBUG` environment variable to
32
32
<aname="reporting-exceptions"></a>
33
33
### Reporting Exceptions
34
34
35
-
In Laravel, exception reporting is used to log exceptions or send them to an external service [Sentry](https://github.com/getsentry/sentry-laravel) or [Flare](https://flareapp.io). By default, exceptions will be logged based on your [logging](/docs/{{version}}/logging) configuration. However, you are free to log exceptions however you wish.
35
+
In Laravel, exception reporting is used to log exceptions or send them to an external service like [Sentry](https://github.com/getsentry/sentry-laravel) or [Flare](https://flareapp.io). By default, exceptions will be logged based on your [logging](/docs/{{version}}/logging) configuration. However, you are free to log exceptions however you wish.
36
36
37
37
If you need to report different types of exceptions in different ways, you may use the `report` exception method in your application's `bootstrap/app.php` to register a closure that should be executed when an exception of a given type needs to be reported. Laravel will determine what type of exception the closure reports by examining the type-hint of the closure:
Copy file name to clipboardexpand all lines: notifications.md
+22-14
Original file line number
Diff line number
Diff line change
@@ -99,7 +99,7 @@ use App\Notifications\InvoicePaid;
99
99
$user->notify(new InvoicePaid($invoice));
100
100
```
101
101
102
-
> [!NOTE]
102
+
> [!NOTE]
103
103
> Remember, you may use the `Notifiable` trait on any of your models. You are not limited to only including it on your `User` model.
104
104
105
105
<aname="using-the-notification-facade"></a>
@@ -124,7 +124,7 @@ Notification::sendNow($developers, new DeploymentCompleted($deployment));
124
124
125
125
Every notification class has a `via` method that determines on which channels the notification will be delivered. Notifications may be sent on the `mail`, `database`, `broadcast`, `vonage`, and `slack` channels.
126
126
127
-
> [!NOTE]
127
+
> [!NOTE]
128
128
> If you would like to use other delivery channels such as Telegram or Pusher, check out the community driven [Laravel Notification Channels website](http://laravel-notification-channels.com).
129
129
130
130
The `via` method receives a `$notifiable` instance, which will be an instance of the class to which the notification is being sent. You may use `$notifiable` to determine which channels the notification should be delivered on:
@@ -144,7 +144,7 @@ public function via(object $notifiable): array
144
144
<aname="queueing-notifications"></a>
145
145
### Queueing Notifications
146
146
147
-
> [!WARNING]
147
+
> [!WARNING]
148
148
> Before queueing notifications you should configure your queue and [start a worker](/docs/{{version}}/queues#running-the-queue-worker).
149
149
150
150
Sending notifications can take time, especially if the channel needs to make an external API call to deliver the notification. To speed up your application's response time, let your notification be queued by adding the `ShouldQueue` interface and `Queueable` trait to your class. The interface and trait are already imported for all notifications generated using the `make:notification` command, so you may immediately add them to your notification class:
@@ -337,7 +337,7 @@ class InvoicePaid extends Notification implements ShouldQueue
337
337
}
338
338
```
339
339
340
-
> [!NOTE]
340
+
> [!NOTE]
341
341
> 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).
@@ -417,14 +417,14 @@ public function toMail(object $notifiable): MailMessage
417
417
}
418
418
```
419
419
420
-
> [!NOTE]
420
+
> [!NOTE]
421
421
> Note we are using `$this->invoice->id` in our `toMail` method. You may pass any data your notification needs to generate its message into the notification's constructor.
422
422
423
423
In this example, we register a greeting, a line of text, a call to action, and then another line of text. These methods provided by the `MailMessage` object make it simple and fast to format small transactional emails. The mail channel will then translate the message components into a beautiful, responsive HTML email template with a plain-text counterpart. Here is an example of an email generated by the `mail` channel:
> When sending mail notifications, be sure to set the `name` configuration option in your `config/app.php` configuration file. This value will be used in the header and footer of your mail notification messages.
429
429
430
430
<aname="error-messages"></a>
@@ -602,7 +602,7 @@ public function toMail(object $notifiable): MailMessage
602
602
}
603
603
```
604
604
605
-
> [!NOTE]
605
+
> [!NOTE]
606
606
> The `attach` method offered by notification mail messages also accepts [attachable objects](/docs/{{version}}/mail#attachable-objects). Please consult the comprehensive [attachable object documentation](/docs/{{version}}/mail#attachable-objects) to learn more.
607
607
608
608
When attaching files to a message, you may also specify the display name and / or MIME type by passing an `array` as the second argument to the `attach` method:
> If your notifiable models are using [UUID or ULID primary keys](/docs/{{version}}/eloquent#uuid-and-ulid-keys), you should replace the `morphs` method with [`uuidMorphs`](/docs/{{version}}/migrations#column-method-uuidMorphs) or [`ulidMorphs`](/docs/{{version}}/migrations#column-method-ulidMorphs) in the notification table migration.
921
921
922
922
<aname="formatting-database-notifications"></a>
@@ -939,18 +939,26 @@ public function toArray(object $notifiable): array
939
939
}
940
940
```
941
941
942
-
When the notification is stored in your application's database, the `type` column will be populated with the notification's class name. However, you may customize this behavior by defining a `databaseType` method on your notification class:
942
+
When a notification is stored in your application's database, the `type` column will be set to the notification's class name by default, and the `read_at` column will be `null`. However, you can customize this behavior by defining the `databaseType` and `initialDatabaseReadAtValue` methods in your notification class:
943
+
944
+
use Illuminate\Support\Carbon;
943
945
944
946
```php
945
947
/**
946
948
* Get the notification's database type.
947
-
*
948
-
* @return string
949
949
*/
950
950
public function databaseType(object $notifiable): string
951
951
{
952
952
return 'invoice-paid';
953
953
}
954
+
955
+
/**
956
+
* Get the initial value for the "read_at" column.
957
+
*/
958
+
public function initialDatabaseReadAtValue(): ?Carbon
959
+
{
960
+
return null;
961
+
}
954
962
```
955
963
956
964
<aname="todatabase-vs-toarray"></a>
@@ -981,7 +989,7 @@ foreach ($user->unreadNotifications as $notification) {
981
989
}
982
990
```
983
991
984
-
> [!NOTE]
992
+
> [!NOTE]
985
993
> 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.
986
994
987
995
<aname="marking-notifications-as-read"></a>
@@ -1323,7 +1331,7 @@ public function toSlack(object $notifiable): SlackMessage
1323
1331
"type":"plain_text",
1324
1332
"text":"Team Announcement"
1325
1333
}
1326
-
},
1334
+
},
1327
1335
{
1328
1336
"type":"section",
1329
1337
"text":{
@@ -1466,7 +1474,7 @@ class User extends Authenticatable
1466
1474
<aname="notifying-external-slack-workspaces"></a>
1467
1475
### Notifying External Slack Workspaces
1468
1476
1469
-
> [!NOTE]
1477
+
> [!NOTE]
1470
1478
> Before sending notifications to external Slack workspaces, your Slack App must be [distributed](#slack-app-distribution).
1471
1479
1472
1480
Of course, you will often want to send notifications to the Slack workspaces owned by your application's users. To do so, you will first need to obtain a Slack OAuth token for the user. Thankfully, [Laravel Socialite](/docs/{{version}}/socialite) includes a Slack driver that will allow you to easily authenticate your application's users with Slack and [obtain a bot token](/docs/{{version}}/socialite#slack-bot-scopes).
Copy file name to clipboardexpand all lines: responses.md
+33
Original file line number
Diff line number
Diff line change
@@ -400,6 +400,39 @@ Route::get('/users.json', function () {
400
400
});
401
401
```
402
402
403
+
<aname="event-streams"></a>
404
+
#### Event Streams
405
+
406
+
The `eventStream` method may be used to return a server-sent events (SSE) streamed response using the `text/event-stream` content type. The `eventStream` method accepts a closure which should [yield](https://www.php.net/manual/en/language.generators.overview.php) responses to the stream as the responses become available:
This event stream may be consumed via an [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) object by your application's frontend. The `eventStream` method will automatically send a `</stream>` update to the event stream when the stream is complete:
0 commit comments