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 Curator Laravel Package

awcodes/filament-curator

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup Steps

  1. Installation:
    composer require awcodes/filament-curator
    php artisan curator:install
    
  2. Add Modal to Layout (if using standalone forms):
    <x-curator::modals.modal />
    
  3. Configure Theme (if using Filament Panels):
    @import '../../../../vendor/awcodes/filament-curator/resources/css/plugin.css';
    @source '../../../../vendor/awcodes/filament-curator/resources/**/*.blade.php';
    

First Use Case

Add a CuratorPicker to a Filament form:

use Awcodes\Curator\Components\Forms\CuratorPicker;

CuratorPicker::make('image')
    ->label('Featured Image')
    ->required();

Implementation Patterns

Core Workflows

  1. Media Management:

    • Use CuratorPicker in forms for uploads/selection.
    • Leverage CuratorColumn in tables for display:
      CuratorColumn::make('image')->size(40);
      
  2. Relationships:

    • Single: Define a belongsTo relationship with Curator\Models\Media.
    • Multiple: Use belongsToMany with pivot order:
      CuratorPicker::make('gallery')
          ->multiple()
          ->relationship('gallery', 'id')
          ->orderColumn('order');
      
  3. Rich Editor Integration:

    RichEditor::make('content')
        ->plugins([AttachCuratorMediaPlugin::make()]);
    

Integration Tips

  • Path Generation: Customize storage paths per instance:
    CuratorPicker::make('avatar')
        ->pathGenerator(DatePathGenerator::class);
    
  • Curations: Predefine presets for reusable image transformations:
    Curation::presets([
        CurationPreset::make('Thumbnail')->width(200)->height(200),
    ]);
    
  • Blade Components: Use <x-curator-glider> for dynamic image rendering:
    <x-curator-glider :media="$media" width="300" height="300" />
    

Gotchas and Tips

Pitfalls

  1. Spatie Media Library Conflict:

    • Gotcha: Curator does not work with Spatie Media Library.
    • Fix: Use either Curator or Spatie, not both.
  2. N+1 Queries in Tables:

    • Gotcha: CuratorColumn triggers N+1 queries without eager loading.
    • Fix: Modify table query to eager load relationships:
      protected function getTableQuery(): Builder {
          return parent::getTableQuery()->with('media');
      }
      
  3. Missing Modal:

    • Gotcha: Forgetting to include <x-curator::modals.modal /> in layouts (standalone forms).
    • Fix: Add the modal before closing </body>.
  4. Custom Model Overrides:

    • Gotcha: Forgetting to update the config after extending Curator\Models\Media.
    • Fix: Set the custom model in config/curator.php:
      'model' => \App\Models\CustomMedia::class,
      

Debugging Tips

  • Image Not Loading?:
    • Verify the disk and directory in config/curator.php.
    • Check Glide routes (/curator by default) are accessible.
  • Curations Missing:
    • Ensure presets are registered in a service provider’s register() method.
    • Use the fallback pattern in Blade:
      @if($media->hasCuration('thumbnail'))
          <x-curator-curation :media="$media" curation="thumbnail" />
      @else
          <x-curator-glider :media="$media" width="200" height="200" />
      @endif
      

Extension Points

  1. Custom Path Generators: Implement Awcodes\Curator\PathGenerators\PathGenerator for unique storage logic.
  2. Glide Fallbacks: Register custom fallbacks for missing media:
    Glide::registerGliderFallbacks([
        GliderFallback::make('placeholder')
            ->source('placeholder.jpg')
            ->width(100)
            ->height(100),
    ]);
    
  3. Curator Events: Listen for curator.media.created or curator.media.deleted to extend functionality.

Performance Quirks

  • Signed URLs: Use force="true" in <x-curator-glider> for cloud storage (e.g., S3), but cache aggressively.
  • Lazy Loading: Defaults to true for CuratorPicker; disable with lazyLoad(false) if needed.
  • Image Resizing: Pre-generate curations for frequently used sizes to avoid runtime processing.
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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor