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: docs-v3/content/docs/mcp/fields.md
+133Lines changed: 133 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -344,6 +344,138 @@ class PostRepository extends Repository
344
344
}
345
345
```
346
346
347
+
## File Field with Custom Filenames
348
+
349
+
The File field supports custom filenames from request data, perfect for automation workflows like n8n where you want to control the filename during upload.
350
+
351
+
### Basic File Upload
352
+
353
+
```php
354
+
class ExpenseRepository extends Repository
355
+
{
356
+
public function fields(RestifyRequest $request): array
357
+
{
358
+
return [
359
+
field('receipt_path')->file()
360
+
->path('expense_receipts/'.Auth::id())
361
+
->storeOriginalName('receipt_filename')
362
+
->storeSize('receipt_size')
363
+
->deletable()
364
+
->disk('s3'),
365
+
366
+
field('receipt_filename')
367
+
->description('Original filename of the uploaded receipt.'),
368
+
369
+
field('receipt_size')
370
+
->description('Size of the uploaded receipt in bytes.'),
371
+
];
372
+
}
373
+
}
374
+
```
375
+
376
+
### Custom Filename from Request
377
+
378
+
Use `storeAs()` with a callback to read the custom filename from the request:
The file will be stored as `expense_receipts/123/Invoice_ABC_Company_Jan_2024.pdf` and the `receipt_filename` column will contain `Invoice_ABC_Company_Jan_2024.pdf`.
478
+
347
479
## Best Practices
348
480
349
481
### 1. Field Selection Strategy
@@ -358,6 +490,7 @@ class PostRepository extends Repository
358
490
- Inline simple relationship data instead of separate API calls
359
491
- Use computed fields to provide aggregated information
360
492
- Avoid deeply nested relationship structures
493
+
- Hide file fields from MCP using `hideFromMcp()` to save tokens
0 commit comments