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
This document provides a high-level overview of major features and changes in Laravel Restify. For detailed documentation and implementation guides, please refer to the comprehensive documentation.
4
+
5
+
## Version 10.x
6
+
7
+
### 🚀 Major Features
8
+
9
+
#### Model Context Protocol (MCP) Integration
10
+
11
+
Laravel Restify now provides seamless integration with the Model Context Protocol (MCP), allowing AI agents to interact with your REST API resources through structured tool interfaces. Transform your repositories into tools for AI agents to consume!
12
+
13
+
**Quick Setup:**
14
+
```php
15
+
use Binaryk\LaravelRestify\MCP\RestifyServer;
16
+
use Laravel\Mcp\Facades\Mcp;
17
+
18
+
// Web-based MCP server with authentication
19
+
Mcp::web('restify', RestifyServer::class)
20
+
->middleware(['auth:sanctum'])
21
+
->name('mcp.restify');
22
+
```
23
+
24
+
**Key Benefits:** AI-Ready APIs, Zero Configuration, Built-in Security, Web & Terminal Access
Copy file name to clipboardExpand all lines: UPGRADING.md
+93Lines changed: 93 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,6 +119,92 @@ class UserRepository extends Repository
119
119
120
120
This change is also **100% backward compatible** - existing static arrays continue to work perfectly.
121
121
122
+
#### Enhanced BelongsTo Search Performance with Configurable JOINs
123
+
124
+
Laravel Restify v10 introduces a significant performance optimization for BelongsTo relationship searches by replacing slow subqueries with efficient JOINs. This feature is configurable and enabled by default for better performance.
125
+
126
+
**Performance Impact:**
127
+
128
+
**Before (v9 and earlier - Subquery approach):**
129
+
```sql
130
+
-- Slow subquery-based search
131
+
SELECT*FROM users WHERE (
132
+
(SELECT name FROM organizations WHEREorganizations.id=users.organization_idLIMIT1) LIKE'%Tech%'
133
+
OR
134
+
(SELECT phone FROM organizations WHEREorganizations.id=users.organization_idLIMIT1) LIKE'%Tech%'
135
+
)
136
+
```
137
+
138
+
**After (v10 - Optimized JOIN approach):**
139
+
```sql
140
+
-- Fast JOIN-based search with proper column selection
141
+
SELECT users.*FROM users
142
+
LEFT JOIN organizations ONusers.organization_id=organizations.id
143
+
WHERE (organizations.nameLIKE'%Tech%'ORorganizations.phoneLIKE'%Tech%')
144
+
```
145
+
146
+
**Configuration Options:**
147
+
148
+
The JOIN optimization can be controlled via configuration:
149
+
150
+
```php
151
+
// config/restify.php
152
+
'search' => [
153
+
'case_sensitive' => true,
154
+
155
+
/*
156
+
| Use JOINs for BelongsTo Relationships
157
+
| When enabled, BelongsTo relationship searches will use JOINs instead of
158
+
| subqueries for better performance. This is generally recommended for
159
+
| better query performance, but can be disabled if compatibility issues arise.
160
+
| Default: true (recommended for better performance)
This change is **100% backward compatible** with an option to disable if needed. The optimization is transparent to your application code while providing significant performance improvements.
207
+
122
208
## Breaking Changes
123
209
124
210
### Default Search Behavior Change
@@ -179,6 +265,13 @@ When upgrading to v10, it's important to ensure your local `config/restify.php`
179
265
180
266
```php
181
267
// Example new sections (check the actual config file for current options)
268
+
'search' => [
269
+
'case_sensitive' => true,
270
+
271
+
// New: JOIN optimization for BelongsTo searches (v10+)
Copy file name to clipboardExpand all lines: docs-v2/content/en/api/fields.md
+73Lines changed: 73 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1374,6 +1374,79 @@ class AvatarStore implements Storable
1374
1374
You can use the <code>php artisan restify:store AvatarStore</code> command to generate a store file.
1375
1375
</alert>
1376
1376
1377
+
## Lazy Loading
1378
+
1379
+
Fields can be configured to lazy load relationships, which is particularly useful for computed attributes that depend on related models. This helps avoid N+1 queries by ensuring relationships are loaded only when needed.
1380
+
1381
+
### Making Fields Lazy
1382
+
1383
+
Use the `lazy()` method to mark a field for lazy loading:
1384
+
1385
+
```php
1386
+
public function fields(RestifyRequest $request)
1387
+
{
1388
+
return [
1389
+
// Lazy load the 'tags' relationship when displaying profileTagNames
0 commit comments