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

Filament Copyactions Laravel Package

webbingbrasil/filament-copyactions

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install the package:

    composer require webbingbrasil/filament-copyactions
    

    Ensure version compatibility with your Filament major version (check the compatibility table).

  2. Publish assets (if needed):

    php artisan vendor:publish --provider="WebbingBrasil\FilamentCopyActions\FilamentCopyActionsServiceProvider"
    
  3. First use case: Replace a standard TextColumn with CopyTextColumn in your Filament table:

    use WebbingBrasil\FilamentCopyActions\Columns\CopyTextColumn;
    
    CopyTextColumn::make('name')
        ->label('Full Name')
        ->copyable(),
    

Implementation Patterns

Table Actions

Dynamic Copy Actions in Tables

  • Use CopyAction for bulk or row-level copying:
    use WebbingBrasil\FilamentCopyActions\Actions\CopyAction;
    
    CopyAction::make('copy_email')
        ->label('Copy Email')
        ->action(function (Table $table, array $records) {
            $emails = $records->pluck('email')->implode(', ');
            return response()->json(['content' => $emails]);
        }),
    

Workflow:

  1. Define the action in your table’s getActions().
  2. Use action() to return JSON with a content key.
  3. The package handles clipboard writing and UI feedback.

Form Actions

Copy Field Values

  • Attach to form fields (e.g., TextInput):
    use WebbingBrasil\FilamentCopyActions\Actions\FormCopyAction;
    
    TextInput::make('description')
        ->extraAttributes(['x-copy-action' => FormCopyAction::make()]),
    

Integration Tip:

  • Use extraAttributes() to avoid modifying field classes.
  • Works with any field type (e.g., RichEditor, Select).

Page Actions

Global Copy Buttons

  • Add to Filament pages (e.g., Pages\CreatePost):
    use WebbingBrasil\FilamentCopyActions\Actions\PageCopyAction;
    
    PageCopyAction::make('copy_metadata')
        ->label('Copy Metadata')
        ->action(function () {
            return ['content' => 'author=John Doe; date=' . now()->format('Y-m-d')];
        }),
    

Best Practice:

  • Place in getHeaderActions() or getFooterActions().
  • Useful for copying pre-generated content (e.g., API keys, templates).

Custom Columns

Enhanced TextColumn

  • Replace:
    TextColumn::make('slug')->copyable(), // Filament 3+
    
  • With:
    CopyTextColumn::make('slug')
        ->copyable()
        ->copyLabel('Copy Slug'),
    

Advanced Usage:

  • Chain with other modifiers:
    CopyTextColumn::make('content')
        ->limit(50)
        ->copyable()
        ->copyLabel(fn ($record) => "Copy {$record->title}'s snippet"),
    

Gotchas and Tips

Clipboard API Limitations

  • HTTPS Requirement: Copy actions fail on http:// (except localhost).
    • Fix: Use https:// in production or test locally.
  • Browser Support: Modern browsers only (Chrome, Firefox, Edge).
    • Fallback: Show a tooltip: "Copy not supported in your browser".

Debugging

  • No Clipboard Write? Check:
    1. The content key exists in the JSON response.
    2. No JavaScript errors (inspect browser console).
    3. The action’s action() method returns valid data:
      return response()->json(['content' => 'test']);
      

Configuration Quirks

  • Default Copy Label: Override globally in config/filament-copy-actions.php:
    'copy_label' => 'Copy to Clipboard',
    

Extension Points

  • Custom Tooltips: Extend the CopyAction class to modify feedback:

    CopyAction::make('custom_copy')
        ->tooltipped(fn ($action) => 'Copied: ' . $action->getContent()),
    
  • Async Copy: For large data, use Laravel queues:

    CopyAction::make('export_data')
        ->action(function () {
            CopyDataJob::dispatch();
            return response()->json(['content' => 'Exporting...']);
        }),
    

Performance

  • Avoid Heavy Computations: Copy actions trigger on user interaction—keep action() methods lightweight.
    • Anti-pattern:
      // Slow: Processes all records on copy
      CopyAction::make('copy_all')
          ->action(fn () => HeavyModel::processEverything()),
      
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.
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
anil/file-picker
broqit/fields-ai