Skip to content

Commit 05c66d5

Browse files
committed
Update README
1 parent 45877ae commit 05c66d5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,30 @@ class EditContent extends EditRecord
164164
}
165165
```
166166

167+
#### Conditionally show the fields relation manager
168+
169+
To conditionally show the fields relation manager, you can override the `canViewForRecord` method in your relation manager.
170+
171+
```php
172+
<?php
173+
174+
namespace App\Filament\Resources\ContentResource\RelationManagers;
175+
176+
use Illuminate\Database\Eloquent\Model;
177+
use Vormkracht10\Fields\Filament\RelationManagers\FieldsRelationManager as RelationManagersFieldsRelationManager;
178+
179+
class FieldsRelationManager extends RelationManagersFieldsRelationManager
180+
{
181+
public static function canViewForRecord(Model $ownerRecord, string $pageClass): bool
182+
{
183+
parent::canViewForRecord($ownerRecord, $pageClass);
184+
185+
// Add your own logic here
186+
return ! $ownerRecord->hasPdf();
187+
}
188+
}
189+
```
190+
167191
### Making a custom page configurable
168192

169193
To make a custom page configurable, you need to add the `HasFieldsMapper` trait to your page and set the `record` property on the page. This way the fields will be populated with the fields of the record.

0 commit comments

Comments
 (0)