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

Laravel Filament News Laravel Package

novius/laravel-filament-news

Filament v4 plugin to manage news posts in Laravel 11+: create posts with categories and tags, attach multiple of each, and browse categories as listing pages. Includes migrations and optional config to customize routes, locales, and resource/model overrides.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to First Use

  1. Installation:
    composer require novius/laravel-filament-news
    php artisan migrate
    
  2. Register Plugin: Add NewsPlugin::make() to your AdminFilamentPanelProvider:
    public function panel(Panel $panel): Panel {
        return $panel->plugins([
            NewsPlugin::make(),
        ]);
    }
    
  3. Access Admin Panel: Navigate to /admin/news/posts to manage posts, categories, and tags via Filament’s UI.

First Use Case: Publishing a Blog Post

  1. Create a Post:
    • Go to PostsCreate Post.
    • Fill in title, content (using Filament’s rich text editor), and assign categories/tags.
    • Save and publish.
  2. View Publicly:
    • Use the publish-front command to generate routes:
      php artisan news-manager:publish-front
      
    • Access /posts or /categories/{slug} to see the post.

Implementation Patterns

Core Workflows

1. Content Management

  • Posts: Use Filament’s resource for CRUD (title, slug, content, status).
    // Customize fields in PostResource.php
    public static function form(Form $form): Form {
        return $form
            ->schema([
                TextInput::make('title')->required(),
                RichEditor::make('content')->required(),
                Select::make('status')->options(['draft', 'published']),
                // ...
            ]);
    }
    
  • Categories/Tags: Manage hierarchies via Filament’s tree or table views.
    // Override CategoryResource to add parent-child relationships
    public static function table(Table $table): Table {
        return $table->columns([
            TextColumn::make('name'),
            TextColumn::make('slug'),
            // ...
        ]);
    }
    

2. Frontend Integration

  • Routes: Publish default routes or customize via config/laravel-filament-news.php:
    'front_routes_name' => [
        'posts' => 'blog.index',
        'post' => 'blog.show',
    ],
    
  • Controller: Extend App\Http\Controllers\NewsController to add logic (e.g., pagination, filters):
    public function index() {
        return view('blog.index', [
            'posts' => \Novius\LaravelFilamentNews\Models\NewsPost::published()->latest()->get(),
        ]);
    }
    

3. Localization

  • Multi-Language Support: Use spatie/laravel-translatable (required for i18n):
    composer require spatie/laravel-translatable
    
    • Publish translations:
      php artisan vendor:publish --provider="Novius\LaravelFilamentNews\LaravelFilamentNewsServiceProvider" --tag="lang"
      
    • Configure locales in config/laravel-filament-news.php:
      'locales' => ['en', 'fr'],
      

4. Extending Functionality

  • Custom Fields: Add fields to resources (e.g., featured_image):
    // In PostResource.php
    public static function form(Form $form): Form {
        return $form->schema([
            // ...
            FileUpload::make('featured_image')->image()->maxSize(2048),
        ]);
    }
    
  • Validation: Override validation rules:
    public static function getValidationRules(): array {
        return [
            'title' => 'required|string|max:255',
            'content' => 'required|string',
            'featured_image' => 'nullable|image|mimes:jpeg,png',
        ];
    }
    

5. API Endpoints (Optional)

  • Use Laravel’s built-in API resources or Filament’s API features:
    // routes/api.php
    Route::apiResource('posts', \Novius\LaravelFilamentNews\Http\Controllers\Api\PostController::class);
    

Gotchas and Tips

Pitfalls

  1. AGPL License:

    • Risk: AGPL requires open-sourcing modified code if distributed.
    • Mitigation: Fork the package or use a commercial license if available.
  2. Filament Version Lock:

    • Issue: Hard dependency on Filament 4+. Downgrading may break functionality.
    • Fix: Test thoroughly if upgrading Filament.
  3. No Built-in API:

    • Problem: Frontend must be built separately (no REST/GraphQL endpoints).
    • Workaround: Create custom API routes or use Filament’s API features.
  4. Limited Frontend Templates:

    • Challenge: Public views require manual Blade template creation.
    • Tip: Use the publish-front command as a starting point, then customize.
  5. Localization Gaps:

    • Issue: Requires spatie/laravel-translatable for multi-language support.
    • Solution: Install the package and configure locales in the config.
  6. Route Conflicts:

    • Problem: Default routes may clash with existing routes.
    • Fix: Override route names in config/laravel-filament-news.php:
      'front_routes_name' => [
          'posts' => 'custom.blog.index',
      ],
      

Debugging Tips

  1. Migration Issues:

    • If migrations fail, publish and customize them:
      php artisan vendor:publish --provider="Novius\LaravelFilamentNews\LaravelFilamentNewsServiceProvider" --tag="migrations"
      
    • Rename tables in config/models.php if conflicts arise.
  2. Filament Plugin Not Loading:

    • Ensure NewsPlugin::make() is added to the panel() method in AdminFilamentPanelProvider.
    • Clear Filament cache:
      php artisan filament:cache-reset
      
  3. Rich Text Editor Not Working:

    • Verify trix or ckeditor is installed (Filament’s default rich editor dependency).
    • Install via:
      npm install @filament/trix @filament/ckeditor
      
  4. Performance with Large Datasets:

    • Optimize queries in PostResource:
      public static function getTableQuery(): Builder {
          return parent::getTableQuery()->with(['categories', 'tags']);
      }
      
    • Use eager loading to avoid N+1 queries.

Extension Points

  1. Custom Resources/Models:

    • Override defaults in config/laravel-filament-news.php:
      'resources' => [
          'post' => App\Filament\Resources\CustomPostResource::class,
      ],
      'models' => [
          'post' => App\Models\CustomPost::class,
      ],
      
  2. Adding Custom Fields:

    • Extend PostResource to include additional fields (e.g., SEO metadata):
      public static function form(Form $form): Form {
          return $form->schema([
              // ...
              TextInput::make('meta_title')->required(),
              Textarea::make('meta_description'),
          ]);
      }
      
  3. Customizing Frontend Views:

    • Publish the front controller and override templates:
      php artisan news-manager:publish-front
      
    • Modify resources/views/vendor/news-manager/ to match your design system.
  4. Integrating with Media Libraries:

    • Use Filament’s FileUpload or MediaLibrary packages to attach images/videos:
      FileUpload::make('thumbnail')->image()->maxSize(2048),
      
  5. Adding Widgets:

    • Create Filament widgets for dashboards (e.g., trending posts):
      public static function getWidgets(): array {
          return [
              PostStatsWidget::class,
          ];
      }
      

Pro Tips

  • Use Filament’s Hooks for dynamic behavior:
    // In PostResource.php
    protected static function getPages(): array {
        return [
            'create' => Pages\CreatePost::route('/'),
            'edit' => Pages\EditPost::route('/{record}/edit'),
        ];
    }
    
  • Leverage Filament’s Actions for bulk operations:
    public static function getTableActions(): array {
        return [
            Tables\Actions\DeleteAction::make(),
            Tables\Actions\ForceDeleteAction::make(),
        ];
    }
    
  • Test Locally with a subset of data before deploying to production.
  • Monitor Performance using Laravel Debugbar or Filament’s built-in profiling tools.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony