mirror of
https://github.com/filamentphp/filament.git
synced 2026-08-30 17:07:25 +08:00
Update 07-managing-relationships.md
This commit is contained in:
@@ -1023,6 +1023,22 @@ public function table(Table $table): Table
|
||||
}
|
||||
```
|
||||
|
||||
<Aside variant="danger">
|
||||
`modifyQueryUsing()` scopes the query for records that already belong to the relationship — the table listing, and actions that operate on its rows, such as `DetachAction`, `DissociateAction`, and bulk actions. It is **not** applied to the records available to `AttachAction` or `AssociateAction`, since those records are outside the relationship by definition.
|
||||
|
||||
To restrict which records may be attached or associated, scope the options using the `recordSelectOptionsQuery()` method on the action. Filament resolves the submitted record against that query, so records outside it are rejected, even if a user tampers with the submitted modal state:
|
||||
|
||||
```php
|
||||
use Filament\Actions\AttachAction;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
AttachAction::make()
|
||||
->recordSelectOptionsQuery(fn (Builder $query) => $query->where('is_active', true))
|
||||
```
|
||||
|
||||
Learn more about scoping the options to [attach](#scoping-the-options-to-attach) or [associate](#scoping-the-options-to-associate).
|
||||
</Aside>
|
||||
|
||||
## Customizing the relation manager title
|
||||
|
||||
To set the title of the relation manager, you can use the `$title` property on the relation manager class:
|
||||
|
||||
Reference in New Issue
Block a user