May Sale! All accounts are 40% off this week.

CodyMcCode's avatar

Editing a Filament v3 Plugin

Hello,

I am using this package: https://github.com/bytexr/filament-queueable-bulk-actions

I need to move the navigation item into a group and change some other things (visually) on how this works. My question is I obviously need to leave the vendor files as they stand but how do I edit these items.

The settings in questions are in the src/Filament/Resources>/BulkActionResource.php file.

Do I publish this and edit it there and if so how?

0 likes
2 replies
CodyMcCode's avatar

Larry, I need some help in here. Why you snoozing?

LaryAI's avatar
Level 58

To customize a Filament plugin without directly modifying the vendor files, you can extend the plugin's functionality in your own application code. Here’s a step-by-step guide on how to achieve this:

  1. Create a Custom Resource:

    • Instead of modifying the vendor files directly, you can create a new resource in your application that extends the existing resource from the plugin.
  2. Extend the Existing Resource:

    • Create a new resource file in your application and extend the BulkActionResource from the plugin.
  3. Customize the Navigation Group:

    • Override the navigationGroup method to move the navigation item into a group.
  4. Customize Other Visual Elements:

    • Override other methods or properties as needed to change the visual aspects.

Here’s an example of how you can do this:

// app/Filament/Resources/CustomBulkActionResource.php

namespace App\Filament\Resources;

use Bytexr\FilamentQueueableBulkActions\Filament\Resources\BulkActionResource as BaseBulkActionResource;
use Filament\Resources\Resource;

class CustomBulkActionResource extends BaseBulkActionResource
{
    public static function navigationGroup(): ?string
    {
        return 'Custom Group';
    }

    // Override other methods or properties as needed
}
  1. Register the Custom Resource:
    • Ensure that your custom resource is registered in the Filament configuration.
// app/Providers/FilamentServiceProvider.php

namespace App\Providers;

use App\Filament\Resources\CustomBulkActionResource;
use Filament\PluginServiceProvider;
use Filament\Resources\Resource;

class FilamentServiceProvider extends PluginServiceProvider
{
    public function boot()
    {
        parent::boot();

        // Register your custom resource
        Resource::register(CustomBulkActionResource::class);
    }
}
  1. Disable the Original Resource (Optional):
    • If you want to completely replace the original resource, you might need to disable it. This depends on how the plugin is structured and whether it allows for such customization.

By following these steps, you can customize the Filament plugin's resources without directly modifying the vendor files, ensuring that your changes are maintainable and won't be overwritten by future updates to the plugin.

Please or to participate in this conversation.