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
-[Registering the Driver](#registering-the-driver)
@@ -529,6 +530,31 @@ If you would like to release a lock without respecting its current owner, you ma
529
530
Cache::lock('processing')->forceRelease();
530
531
```
531
532
533
+
<aname="cache-failover"></a>
534
+
## Cache Failover
535
+
536
+
The `failover` cache driver provides automatic failover functionality when interacting with the cache. If the primary cache store fails for any reason, Laravel will automatically attempt to use the next configured store in the list. This is particularly useful for ensuring high availability in production environments where cache reliability is critical.
537
+
538
+
To configure a failover cache store, specify the `failover` driver and provide an array of store names to attempt in order. By default, Laravel includes an example failover configuration in your application's `config/cache.php` configuration file:
539
+
540
+
```php
541
+
'failover' => [
542
+
'driver' => 'failover',
543
+
'stores' => [
544
+
'database',
545
+
'array',
546
+
],
547
+
],
548
+
```
549
+
550
+
Once you have configured a store that uses the `failover` driver, you will probably want to set the failover store as your default cache store in your application's `.env` file:
551
+
552
+
```ini
553
+
CACHE_STORE=failover
554
+
```
555
+
556
+
When a cache store operation fails and failover is activated, Laravel will dispatch the `Illuminate\Cache\Events\CacheFailedOver` event, allowing you to report or log that a cache store has failed.
Copy file name to clipboardExpand all lines: original-en/eloquent-factories.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,7 +95,20 @@ The new factory class will be placed in your `database/factories` directory.
95
95
96
96
Once you have defined your factories, you may use the static `factory` method provided to your models by the `Illuminate\Database\Eloquent\Factories\HasFactory` trait in order to instantiate a factory instance for that model.
97
97
98
-
The `HasFactory` trait's `factory` method will use conventions to determine the proper factory for the model the trait is assigned to. Specifically, the method will look for a factory in the `Database\Factories` namespace that has a class name matching the model name and is suffixed with `Factory`. If these conventions do not apply to your particular application or factory, you may overwrite the `newFactory` method on your model to return an instance of the model's corresponding factory directly:
98
+
The `HasFactory` trait's `factory` method will use conventions to determine the proper factory for the model the trait is assigned to. Specifically, the method will look for a factory in the `Database\Factories` namespace that has a class name matching the model name and is suffixed with `Factory`. If these conventions do not apply to your particular application or factory, you may add the `UseFactory` attribute to the model to manually specify the model's factory:
99
+
100
+
```php
101
+
use Illuminate\Database\Eloquent\Attributes\UseFactory;
102
+
use Database\Factories\Administration\FlightFactory;
103
+
104
+
#[UseFactory(FlightFactory::class)]
105
+
class Flight extends Model
106
+
{
107
+
// ...
108
+
}
109
+
```
110
+
111
+
Alternatively, you may overwrite the `newFactory` method on your model to return an instance of the model's corresponding factory directly:
99
112
100
113
```php
101
114
use Database\Factories\Administration\FlightFactory;
Copy file name to clipboardExpand all lines: original-en/eloquent-relationships.md
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2127,17 +2127,16 @@ Sometimes you may wish to eager load a relationship but also specify additional
2127
2127
2128
2128
```php
2129
2129
use App\Models\User;
2130
-
use Illuminate\Database\Eloquent\Builder;
2131
2130
2132
-
$users = User::with(['posts' => function (Builder $query) {
2131
+
$users = User::with(['posts' => function ($query) {
2133
2132
$query->where('title', 'like', '%code%');
2134
2133
}])->get();
2135
2134
```
2136
2135
2137
2136
In this example, Eloquent will only eager load posts where the post's `title` column contains the word `code`. You may call other [query builder](/docs/{{version}}/queries) methods to further customize the eager loading operation:
2138
2137
2139
2138
```php
2140
-
$users = User::with(['posts' => function (Builder $query) {
2139
+
$users = User::with(['posts' => function ($query) {
2141
2140
$query->orderBy('created_at', 'desc');
2142
2141
}])->get();
2143
2142
```
@@ -2195,7 +2194,7 @@ if ($condition) {
2195
2194
If you need to set additional query constraints on the eager loading query, you may pass an array keyed by the relationships you wish to load. The array values should be closure instances which receive the query instance:
2196
2195
2197
2196
```php
2198
-
$author->load(['books' => function (Builder $query) {
When using methods such as `firstOrCreate` or `updateOrCreate`, you may not know whether a new model has been created or an existing one has been updated. The `wasRecentlyCreated` property indicates if the model was created during its current lifecycle:
Copy file name to clipboardExpand all lines: original-en/fortify.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,14 +41,14 @@ As mentioned previously, Laravel Fortify is a frontend agnostic authentication b
41
41
42
42
**You are not required to use Fortify in order to use Laravel's authentication features.** You are always free to manually interact with Laravel's authentication services by following the documentation available in the [authentication](/docs/{{version}}/authentication), [password reset](/docs/{{version}}/passwords), and [email verification](/docs/{{version}}/verification) documentation.
43
43
44
-
If you are new to Laravel, you may wish to explore [our application starter kits](/docs/{{version}}/starter-kits) before attempting to use Laravel Fortify. Our starter kits provide an authentication scaffolding for your application that includes a user interface built with [Tailwind CSS](https://tailwindcss.com). This allows you to study and get comfortable with Laravel's authentication features before allowing Laravel Fortify to implement these features for you.
44
+
If you are new to Laravel, you may wish to explore [our application starter kits](/docs/{{version}}/starter-kits). Laravel's application starter kits use Fortify internally to provide authentication scaffolding for your application that includes a user interface built with [Tailwind CSS](https://tailwindcss.com). This allows you to study and get comfortable with Laravel's authentication features.
45
45
46
46
Laravel Fortify essentially takes the routes and controllers of our application starter kits and offers them as a package that does not include a user interface. This allows you to still quickly scaffold the backend implementation of your application's authentication layer without being tied to any particular frontend opinions.
47
47
48
48
<aname="when-should-i-use-fortify"></a>
49
49
### When Should I Use Fortify?
50
50
51
-
You may be wondering when it is appropriate to use Laravel Fortify. First, if you are using one of Laravel's [application starter kits](/docs/{{version}}/starter-kits), you do not need to install Laravel Fortify since all of Laravel's application starter kits already provide a full authentication implementation.
51
+
You may be wondering when it is appropriate to use Laravel Fortify. First, if you are using one of Laravel's [application starter kits](/docs/{{version}}/starter-kits), you do not need to install Laravel Fortify since all of Laravel's application starter kits use Fortify and already provide a full authentication implementation.
52
52
53
53
If you are not using an application starter kit and your application needs authentication features, you have two options: manually implement your application's authentication features or use Laravel Fortify to provide the backend implementation of these features.
Copy file name to clipboardExpand all lines: original-en/mcp.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -354,7 +354,7 @@ class CurrentWeatherTool extends Tool
354
354
}
355
355
```
356
356
357
-
On validation failure, AI clients will act based on the error messages you provide. As such, is critical to provide clear and actionable error messages:
357
+
On validation failure, AI clients will act based on the error messages you provide. As such, it is critical to provide clear and actionable error messages:
358
358
359
359
```php
360
360
$validated = $request->validate([
@@ -715,7 +715,7 @@ class DescribeWeatherPrompt extends Prompt
715
715
}
716
716
```
717
717
718
-
On validation failure, AI clients will act based on the error messages you provide. As such, is critical to provide clear and actionable error messages:
718
+
On validation failure, AI clients will act based on the error messages you provide. As such, it is critical to provide clear and actionable error messages:
719
719
720
720
```php
721
721
$validated = $request->validate([
@@ -1119,16 +1119,16 @@ return Response::error('Unable to fetch weather data for the specified location.
1119
1119
<aname="authentication"></a>
1120
1120
## Authentication
1121
1121
1122
-
You can authenticate web MCP servers with middleware just like you would for routes. This will require a user to authenticate before using any capability of the server.
1122
+
Just like routes, you can authenticate web MCP servers with middleware. Adding authentication to your MCP server will require a user to authenticate before using any capability of the server.
1123
1123
1124
-
There are two ways to authenticate access to your MCP server: simple, token based authentication via [Laravel Sanctum](/docs/{{version}}/sanctum), or any other arbitrary API tokens which are passed via the `Authorization` HTTP header. Or, you may authenticate via OAuth using [Laravel Passport](/docs/{{version}}/passport).
1124
+
There are two ways to authenticate access to your MCP server: simple, token based authentication via [Laravel Sanctum](/docs/{{version}}/sanctum) or any token which is passed via the `Authorization` HTTP header. Or, you may authenticate via OAuth using [Laravel Passport](/docs/{{version}}/passport).
1125
1125
1126
1126
<aname="oauth"></a>
1127
1127
### OAuth 2.1
1128
1128
1129
-
The most robust way to protect your web-based MCP servers is with OAuth through[Laravel Passport](/docs/{{version}}/passport).
1129
+
The most robust way to protect your web-based MCP servers is with OAuth using[Laravel Passport](/docs/{{version}}/passport).
1130
1130
1131
-
When authenticating your MCP server via OAuth, you will invoke the `Mcp::oauthRoutes` method in your `routes/ai.php` file to register the required OAuth2 discovery and client registration routes. Then, apply Passport's `auth:api` middleware to your `Mcp::web` route in your `routes/ai.php` file:
1131
+
When authenticating your MCP server via OAuth, invoke the `Mcp::oauthRoutes` method in your `routes/ai.php` file to register the required OAuth2 discovery and client registration routes. Then, apply Passport's `auth:api` middleware to your `Mcp::web` route in your `routes/ai.php` file:
If your application is not already using Laravel Passport, start by following Passport's [installation and deployment steps](/docs/{{version}}/passport#installation). You should have an `OAuthenticatable` model, new authentication guard, and passport keys before moving on.
1145
+
If your application is not already using Laravel Passport, follow Passport's [installation and deployment guide](/docs/{{version}}/passport#installation) to add Passport to your application. You should have an `OAuthenticatable` model, new authentication guard, and passport keys before moving on.
1146
1146
1147
1147
Next, you should publish Laravel MCP's provided Passport authorization view:
1148
1148
@@ -1177,7 +1177,7 @@ This view will be displayed to the end-user during authentication to reject or a
1177
1177
1178
1178
If your application is already using Laravel Passport, Laravel MCP should work seamlessly within your existing Passport installation, but custom scopes aren't currently supported as OAuth is primarily used as a translation layer to the underlying authenticatable model.
1179
1179
1180
-
Laravel MCP, via the `Mcp::oauthRoutes()` method discussed above, adds, advertises, and uses a single `mcp:use` scope.
1180
+
Laravel MCP, via the `Mcp::oauthRoutes` method discussed above, adds, advertises, and uses a single `mcp:use` scope.
Sometimes you may need to render two separate paginators on a single screen that is rendered by your application. However, if both paginator instances use the `page` query string parameter to store the current page, the two paginator's will conflict. To resolve this conflict, you may pass the name of the query string parameter you wish to use to store the paginator's current page via the third argument provided to the `paginate`, `simplePaginate`, and `cursorPaginate` methods:
111
+
Sometimes you may need to render two separate paginators on a single screen that is rendered by your application. However, if both paginator instances use the `page` query string parameter to store the current page, the two paginators will conflict. To resolve this conflict, you may pass the name of the query string parameter you wish to use to store the paginator's current page via the third argument provided to the `paginate`, `simplePaginate`, and `cursorPaginate` methods:
0 commit comments