update to getAllRelationManagers

This commit is contained in:
Andrew Wallo
2025-03-22 12:58:43 -04:00
parent d0e9c2a936
commit a6315050c1
2 changed files with 8 additions and 10 deletions
@@ -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,