Skip to content

Commit bc56f6d

Browse files
committed
Merge branch '10.x'
2 parents 871dcf5 + 215d89e commit bc56f6d

10 files changed

+98
-34
lines changed

broadcasting.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ Events are broadcast over "channels", which may be specified as public or privat
306306
307307
Before diving into each component of event broadcasting, let's take a high level overview using an e-commerce store as an example.
308308
309-
In our application, let's assume we have a page that allows users to view the shipping status for their orders. Let's also assume that a `OrderShipmentStatusUpdated` event is fired when a shipping status update is processed by the application:
309+
In our application, let's assume we have a page that allows users to view the shipping status for their orders. Let's also assume that an `OrderShipmentStatusUpdated` event is fired when a shipping status update is processed by the application:
310310
311311
use App\Events\OrderShipmentStatusUpdated;
312312
@@ -696,7 +696,7 @@ However, remember that we also broadcast the task's creation. If your JavaScript
696696
<a name="only-to-others-configuration"></a>
697697
#### Configuration
698698
699-
When you initialize a Laravel Echo instance, a socket ID is assigned to the connection. If you are using a global [Axios](https://github.com/mzabriskie/axios) instance to make HTTP requests from your JavaScript application, the socket ID will automatically be attached to every outgoing request as a `X-Socket-ID` header. Then, when you call the `toOthers` method, Laravel will extract the socket ID from the header and instruct the broadcaster to not broadcast to any connections with that socket ID.
699+
When you initialize a Laravel Echo instance, a socket ID is assigned to the connection. If you are using a global [Axios](https://github.com/mzabriskie/axios) instance to make HTTP requests from your JavaScript application, the socket ID will automatically be attached to every outgoing request as an `X-Socket-ID` header. Then, when you call the `toOthers` method, Laravel will extract the socket ID from the header and instruct the broadcaster to not broadcast to any connections with that socket ID.
700700
701701
If you are not using a global Axios instance, you will need to manually configure your JavaScript application to send the `X-Socket-ID` header with all outgoing requests. You may retrieve the socket ID using the `Echo.socketId` method:
702702
@@ -851,7 +851,7 @@ Echo.join(`chat.${roomId}`)
851851
});
852852
```
853853
854-
The `here` callback will be executed immediately once the channel is joined successfully, and will receive an array containing the user information for all of the other users currently subscribed to the channel. The `joining` method will be executed when a new user joins a channel, while the `leaving` method will be executed when a user leaves the channel. The `error` method will be executed when the authentication endpoint returns a HTTP status code other than 200 or if there is a problem parsing the returned JSON.
854+
The `here` callback will be executed immediately once the channel is joined successfully, and will receive an array containing the user information for all of the other users currently subscribed to the channel. The `joining` method will be executed when a new user joins a channel, while the `leaving` method will be executed when a user leaves the channel. The `error` method will be executed when the authentication endpoint returns an HTTP status code other than 200 or if there is a problem parsing the returned JSON.
855855
856856
<a name="broadcasting-to-presence-channels"></a>
857857
### Broadcasting to Presence Channels
@@ -982,7 +982,7 @@ protected function newBroadcastableEvent(string $event): BroadcastableModelEvent
982982
983983
As you may have noticed, the `broadcastOn` method in the model example above did not return `Channel` instances. Instead, Eloquent models were returned directly. If an Eloquent model instance is returned by your model's `broadcastOn` method (or is contained in an array returned by the method), Laravel will automatically instantiate a private channel instance for the model using the model's class name and primary key identifier as the channel name.
984984
985-
So, an `App\Models\User` model with an `id` of `1` would be converted into a `Illuminate\Broadcasting\PrivateChannel` instance with a name of `App.Models.User.1`. Of course, in addition to returning Eloquent model instances from your model's `broadcastOn` method, you may return complete `Channel` instances in order to have full control over the model's channel names:
985+
So, an `App\Models\User` model with an `id` of `1` would be converted into an `Illuminate\Broadcasting\PrivateChannel` instance with a name of `App.Models.User.1`. Of course, in addition to returning Eloquent model instances from your model's `broadcastOn` method, you may return complete `Channel` instances in order to have full control over the model's channel names:
986986
987987
```php
988988
use Illuminate\Broadcasting\PrivateChannel;

configuration.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,31 @@ php artisan env:decrypt --force
186186
<a name="accessing-configuration-values"></a>
187187
## Accessing Configuration Values
188188

189-
You may easily access your configuration values using the global `config` function from anywhere in your application. The configuration values may be accessed using "dot" syntax, which includes the name of the file and option you wish to access. A default value may also be specified and will be returned if the configuration option does not exist:
189+
You may easily access your configuration values using the `Config` facade or global `config` function from anywhere in your application. The configuration values may be accessed using "dot" syntax, which includes the name of the file and option you wish to access. A default value may also be specified and will be returned if the configuration option does not exist:
190+
191+
use Illuminate\Support\Facades\Config;
192+
193+
$value = Config::get('app.timezone');
190194

191195
$value = config('app.timezone');
192196

193197
// Retrieve a default value if the configuration value does not exist...
194198
$value = config('app.timezone', 'Asia/Seoul');
195199

196-
To set configuration values at runtime, pass an array to the `config` function:
200+
To set configuration values at runtime, you may invoke the `Config` facade's `set` method or pass an array to the `config` function:
201+
202+
Config::set('app.timezone', 'America/Chicago');
197203

198204
config(['app.timezone' => 'America/Chicago']);
199205

206+
To assist with static analysis, the `Config` facade also provides typed configuration retrieval methods. If the retrieved configuration value does not match the expected type, an exception will be thrown:
207+
208+
Config::string('config-key');
209+
Config::integer('config-key');
210+
Config::float('config-key');
211+
Config::boolean('config-key');
212+
Config::array('config-key');
213+
200214
<a name="configuration-caching"></a>
201215
## Configuration Caching
202216

eloquent-resources.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -334,24 +334,6 @@ By default, your outermost resource is wrapped in a `data` key when the resource
334334
}
335335
```
336336

337-
If you would like to use a custom key instead of `data`, you may define a `$wrap` attribute on the resource class:
338-
339-
<?php
340-
341-
namespace App\Http\Resources;
342-
343-
use Illuminate\Http\Resources\Json\JsonResource;
344-
345-
class UserResource extends JsonResource
346-
{
347-
/**
348-
* The "data" wrapper that should be applied.
349-
*
350-
* @var string|null
351-
*/
352-
public static $wrap = 'user';
353-
}
354-
355337
If you would like to disable the wrapping of the outermost resource, you should invoke the `withoutWrapping` method on the base `Illuminate\Http\Resources\Json\JsonResource` class. Typically, you should call this method from your `AppServiceProvider` or another [service provider](/docs/{{version}}/providers) that is loaded on every request to your application:
356338

357339
<?php

prompts.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [Suggest](#suggest)
1212
- [Search](#search)
1313
- [Multi-search](#multisearch)
14+
- [Pause](#pause)
1415
- [Informational Messages](#informational-messages)
1516
- [Tables](#tables)
1617
- [Spin](#spin)
@@ -638,8 +639,19 @@ $ids = multisearch(
638639

639640
If the `options` closure returns an associative array, then the closure will receive the selected keys; otherwise, it will receive the selected values. The closure may return an error message, or `null` if the validation passes.
640641

642+
<a name="pause"></a>
643+
### Pause
644+
645+
The `pause` function may be used to display informational text to the user and wait for them to confirm their desire to proceed by pressing the Enter / Return key:
646+
647+
```php
648+
use function Laravel\Prompts\pause;
649+
650+
pause('Press ENTER to continue.');
651+
```
652+
641653
<a name="informational-messages"></a>
642-
### Informational Messages
654+
## Informational Messages
643655

644656
The `note`, `info`, `warning`, `error`, and `alert` functions may be used to display informational messages:
645657

@@ -650,7 +662,7 @@ info('Package installed successfully.');
650662
```
651663

652664
<a name="tables"></a>
653-
### Tables
665+
## Tables
654666

655667
The `table` function makes it easy to display multiple rows and columns of data. All you need to do is provide the column names and the data for the table:
656668

@@ -664,7 +676,7 @@ table(
664676
```
665677

666678
<a name="spin"></a>
667-
### Spin
679+
## Spin
668680

669681
The `spin` function displays a spinner along with an optional message while executing a specified callback. It serves to indicate ongoing processes and returns the callback's results upon completion:
670682

@@ -733,7 +745,7 @@ $progress->finish();
733745
```
734746

735747
<a name="terminal-considerations"></a>
736-
### Terminal Considerations
748+
## Terminal Considerations
737749

738750
<a name="terminal-width"></a>
739751
#### Terminal Width
@@ -746,7 +758,7 @@ If the length of any label, option, or validation message exceeds the number of
746758
For any prompts that accept the `scroll` argument, the configured value will automatically be reduced to fit the height of the user's terminal, including space for a validation message.
747759

748760
<a name="fallbacks"></a>
749-
### Unsupported Environments and Fallbacks
761+
## Unsupported Environments and Fallbacks
750762

751763
Laravel Prompts supports macOS, Linux, and Windows with WSL. Due to limitations in the Windows version of PHP, it is not currently possible to use Laravel Prompts on Windows outside of WSL.
752764

queries.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,26 @@ You may use the `joinSub`, `leftJoinSub`, and `rightJoinSub` methods to join a q
380380
$join->on('users.id', '=', 'latest_posts.user_id');
381381
})->get();
382382

383+
<a name="lateral-joins"></a>
384+
#### Lateral Joins
385+
386+
> [!WARNING]
387+
> Lateral joins are currently supported by PostgreSQL, MySQL >= 8.0.14, and SQL Server.
388+
389+
You may use the `joinLateral` and `leftJoinLateral` methods to perform a "lateral join" with a subquery. Each of these methods receives two arguments: the subquery and its table alias. The join condition(s) should be specified within the `where` clause of the given subquery. Lateral joins are evaluated for each row and can reference columns outside the subquery.
390+
391+
In this example, we will retrieve a collection of users as well as the user's three most recent blog posts. Each user can produce up to three rows in the result set: one for each of their most recent blog posts. The join condition is specified with a `whereColumn` clause within the subquery, referencing the current user row:
392+
393+
$latestPosts = DB::table('posts')
394+
->select('id as post_id', 'title as post_title', 'created_at as post_created_at')
395+
->whereColumn('user_id', 'users.id')
396+
->orderBy('created_at', 'desc')
397+
->limit(3);
398+
399+
$users = DB::table('users')
400+
->joinLateral($latestPosts, 'latest_posts')
401+
->get();
402+
383403
<a name="unions"></a>
384404
## Unions
385405

queues.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,7 @@ When a particular job fails, you may want to send an alert to your users or reve
18971897
/**
18981898
* Handle a job failure.
18991899
*/
1900-
public function failed(Throwable $exception): void
1900+
public function failed(?Throwable $exception): void
19011901
{
19021902
// Send user notification of failure, etc...
19031903
}

rate-limiting.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,24 @@ If you would like to manually interact with the rate limiter, a variety of other
6666
return 'Too many attempts!';
6767
}
6868

69-
RateLimiter::hit('send-message:'.$user->id);
69+
RateLimiter::increment('send-message:'.$user->id);
7070

7171
// Send message...
7272

73-
Alternatively, you may use the `remaining` method to retrieve the number of attempts remaining for a given key. If a given key has retries remaining, you may invoke the `hit` method to increment the number of total attempts:
73+
Alternatively, you may use the `remaining` method to retrieve the number of attempts remaining for a given key. If a given key has retries remaining, you may invoke the `increment` method to increment the number of total attempts:
7474

7575
use Illuminate\Support\Facades\RateLimiter;
7676

7777
if (RateLimiter::remaining('send-message:'.$user->id, $perMinute = 5)) {
78-
RateLimiter::hit('send-message:'.$user->id);
78+
RateLimiter::increment('send-message:'.$user->id);
7979

8080
// Send message...
8181
}
8282

83+
If you would like to increment the value for a given rate limiter key by more than one, you may provide the desired amount to the `increment` method:
84+
85+
RateLimiter::increment('send-message:'.$user->id, amount: 5);
86+
8387
<a name="determining-limiter-availability"></a>
8488
#### Determining Limiter Availability
8589

@@ -93,7 +97,7 @@ When a key has no more attempts left, the `availableIn` method returns the numbe
9397
return 'You may try again in '.$seconds.' seconds.';
9498
}
9599

96-
RateLimiter::hit('send-message:'.$user->id);
100+
RateLimiter::increment('send-message:'.$user->id);
97101

98102
// Send message...
99103

strings.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ The `Str::isUrl` method determines if the given string is a valid URL:
559559

560560
// false
561561

562+
The `isUrl` method considers a wide range of protocols as valid. However, you may specify the protocols that should be considered valid by providing them to the `isUrl` method:
563+
564+
$isUrl = Str::isUrl('http://example.com', ['http', 'https']);
565+
562566
<a name="method-str-is-ulid"></a>
563567
#### `Str::isUlid()` {.collection-method}
564568

@@ -1758,6 +1762,10 @@ The `isUrl` method determines if a given string is a URL:
17581762

17591763
// false
17601764

1765+
The `isUrl` method considers a wide range of protocols as valid. However, you may specify the protocols that should be considered valid by providing them to the `isUrl` method:
1766+
1767+
$result = Str::of('http://example.com')->isUrl(['http', 'https']);
1768+
17611769
<a name="method-fluent-str-is-uuid"></a>
17621770
#### `isUuid` {.collection-method}
17631771

telescope.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ php artisan telescope:install
5656
php artisan migrate
5757
```
5858

59+
Finally, you may access the Telescope dashboard via the `/telescope` route.
60+
5961
<a name="local-only-installation"></a>
6062
### Local Only Installation
6163

validation.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,28 @@ The `Enum` rule is a class based rule that validates whether the field under val
12451245
'status' => [Rule::enum(ServerStatus::class)],
12461246
]);
12471247

1248+
The `Enum` rule's `only` and `except` methods may be used to limit which enum cases should be considered valid:
1249+
1250+
Rule::enum(ServerStatus::class)
1251+
->only([ServerStatus::Pending, ServerStatus::Active]);
1252+
1253+
Rule::enum(ServerStatus::class)
1254+
->except([ServerStatus::Pending, ServerStatus::Active]);
1255+
1256+
The `when` method may be used to conditionally modify the `Enum` rule:
1257+
1258+
```php
1259+
use Illuminate\Support\Facades\Auth;
1260+
use Illuminate\Validation\Rule;
1261+
1262+
Rule::enum(ServerStatus::class)
1263+
->when(
1264+
Auth::user()->isAdmin(),
1265+
fn ($rule) => $rule->only(...),
1266+
fn ($rule) => $rule->only(...),
1267+
);
1268+
```
1269+
12481270
<a name="rule-exclude"></a>
12491271
#### exclude
12501272

0 commit comments

Comments
 (0)