Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Relation Manager Repeater Laravel Package

zvizvi/relation-manager-repeater

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require zvizvi/relation-manager-repeater
    

    Publish the config (if needed):

    php artisan vendor:publish --provider="Zvizvi\RelationManagerRepeater\RelationManagerRepeaterServiceProvider"
    
  2. First Use Case: Add the RelationManagerRepeaterAction to a Filament 4 RelationManager:

    use Zvizvi\RelationManagerRepeater\Tables\RelationManagerRepeaterAction;
    
    class PostsRelationManager extends RelationManager
    {
        protected static string $relationship = 'posts';
    
        public function table(Table $table): Table
        {
            return $table
                ->columns([/* ... */])
                ->headerActions([
                    RelationManagerRepeaterAction::make(),
                ]);
        }
    }
    
    • Trigger: Click the "Repeater" button in the relation manager header.
    • Result: A modal opens with a repeater-style UI for bulk inline editing of related records.

Implementation Patterns

Core Workflows

  1. Inline Bulk Editing:

    • Use the repeater to edit multiple records at once (e.g., updating title and status for 10 Post models simultaneously).
    • Example:
      RelationManagerRepeaterAction::make()
          ->columns([
              TextColumn::make('title'),
              SelectColumn::make('status')->options(['draft', 'published']),
          ])
          ->bulkActions([/* ... */]);
      
  2. Conditional Repeater Logic:

    • Restrict repeater access via permissions or relationship checks:
      RelationManagerRepeaterAction::make()
          ->can([
              fn ($livewire) => $livewire->getOwnerRecord()->can('manage_posts'),
          ]);
      
  3. Custom Repeater Fields:

    • Extend with custom components (e.g., toggle, date picker):
      ->columns([
          ToggleColumn::make('is_featured'),
          DatePickerColumn::make('published_at'),
      ]);
      
  4. Integration with Filament Forms:

    • Reuse repeater columns in parent resource forms for consistency:
      use Zvizvi\RelationManagerRepeater\Components\RepeaterColumn;
      
      $this->form([
          RepeaterColumn::make('posts')
              ->columns([
                  TextInput::make('title'),
              ]),
      ]);
      
  5. Bulk Actions:

    • Add actions like delete, duplicate, or archive:
      ->bulkActions([
          Tables\Actions\DeleteAction::make(),
          Tables\Actions\DuplicateAction::make(),
      ]);
      

Gotchas and Tips

Pitfalls

  1. Performance with Large Datasets:

    • Repeater loads all related records into memory. For >1000 records, use pagination or lazy-loading:
      RelationManagerRepeaterAction::make()
          ->perPage(50);
      
  2. Model Casting Issues:

    • Ensure related models have proper casts (e.g., published_at as Carbon). Repeater may fail silently on invalid data types.
  3. CSRF Token Conflicts:

    • If the repeater modal fails to save, verify the CSRF token is included in the modal’s form:
      RelationManagerRepeaterAction::make()
          ->extraAttributes(['csrf_token' => csrf_token()]);
      
  4. Relationship Ownership:

    • Repeater assumes the parent model owns the relationship. Misconfigured $relationship causes "not found" errors.

Debugging Tips

  • Check Logs: Enable debug mode (APP_DEBUG=true) to inspect repeater payloads.
  • Inspect Network Requests: Use browser dev tools to verify payloads sent to /filament/relation-manager-repeater.
  • Override Default Behavior:
    RelationManagerRepeaterAction::make()
        ->modifyQueryUsing(fn (Builder $query) => $query->where('active', true));
    

Extension Points

  1. Custom Repeater UI:

    • Override the modal template via resources/views/vendor/filament-relation-manager-repeater/modal.blade.php.
  2. Event Hooks:

    • Listen for relation-manager-repeater.saving or relation-manager-repeater.saved events:
      event(new RelationManagerRepeaterEvent($records, $action));
      
  3. Localization:

    • Translate labels dynamically:
      RelationManagerRepeaterAction::make()
          ->label(__('filament-relation-manager-repeater::repeater.label'));
      
  4. Testing:

    • Use RelationManagerRepeaterAction::make()->test() to simulate repeater interactions in PHPUnit:
      $this->callAction('repeater');
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope