mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
update to getAllRelationManagers
This commit is contained in:
@@ -172,10 +172,10 @@ public function infolist(Infolist $infolist): Infolist
|
||||
|
||||
## Customizing relation managers for a specific view page
|
||||
|
||||
You can specify which relation managers should appear on a view page by defining a `getRelations()` method:
|
||||
You can specify which relation managers should appear on a view page by defining a `getAllRelationManagers()` method:
|
||||
|
||||
```php
|
||||
protected function getRelations(): array
|
||||
protected function getAllRelationManagers(): array
|
||||
{
|
||||
return [
|
||||
CustomerAddressesRelationManager::class,
|
||||
@@ -189,7 +189,7 @@ each page:
|
||||
|
||||
```php
|
||||
// ViewCustomer.php
|
||||
protected function getRelations(): array
|
||||
protected function getAllRelationManagers(): array
|
||||
{
|
||||
return [
|
||||
RelationManagers\OrdersRelationManager::class,
|
||||
@@ -198,7 +198,7 @@ protected function getRelations(): array
|
||||
}
|
||||
|
||||
// ViewCustomerContact.php
|
||||
protected function getRelations(): array
|
||||
protected function getAllRelationManagers(): array
|
||||
{
|
||||
return [
|
||||
RelationManagers\ContactsRelationManager::class,
|
||||
@@ -207,7 +207,7 @@ protected function getRelations(): array
|
||||
}
|
||||
```
|
||||
|
||||
If `getRelations()` isn't defined or returns an empty array, any relation managers defined in the resource will be used.
|
||||
If `getAllRelationManagers` isn't defined or returns an empty array, any relation managers defined in the resource will be used.
|
||||
|
||||
## Adding view pages to resource sub-navigation
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ trait HasRelationManagers
|
||||
/**
|
||||
* @return array<class-string<RelationManager> | RelationGroup | RelationManagerConfiguration>
|
||||
*/
|
||||
protected function getRelations(): array
|
||||
protected function getAllRelationManagers(): array
|
||||
{
|
||||
return [];
|
||||
return $this->getResource()::getRelations();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,9 +26,7 @@ trait HasRelationManagers
|
||||
*/
|
||||
public function getRelationManagers(): array
|
||||
{
|
||||
$managers = filled($relations = $this->getRelations())
|
||||
? $relations
|
||||
: $this->getResource()::getRelations();
|
||||
$managers = $this->getAllRelationManagers();
|
||||
|
||||
return array_filter(
|
||||
$managers,
|
||||
|
||||
Reference in New Issue
Block a user