Why Package Panels0:00
Now, it's not just things like resources, pages, panel configuration that can be moved into your plugin. You can also move the entire panel. There are a few use cases for this. For example, you might want to start selling pre-built panels, and each panel might have a different use case. For example, you might have an e-commerce panel, you might have a user support panel, you might have a learning management panel. All these panels can then be redistributed to your users very easily. Even if you're not thinking about publishing your work, you could use this pattern in your own client projects. For example, maybe you have the same user management system that you've built for one project, and you want to use it across multiple. Or maybe you have a CMS that you've built yourself with Filament that you want to install across all your client projects. You can do this with a plugin.
Move Panel Provider0:48
to use it across multiple. Or maybe you have a CMS that you've built yourself with Filament that you want to install across all your client projects. You can do this with a plugin. All panels are registered in ServiceProviders. This ServiceProvider is really nothing special. You can move this completely into your plugin, just as you expect. So let's move this entire class into the source directory. phpStorm's refactored the namespace for us. And now we don't have this provider in our app anymore. We can remove it from the config/app.php. So let's get rid of that. And let's go into the browser to find a 404. The reason for this is because it's a new ServiceProvider in our plugin. Laravel doesn't know that it exists yet. So let's add it to the composer.json of our plugin so that it gets discovered. Let's add a new item to this array. So danharanFilamentToolkit and then AdminPanelProvider, which matches
Install Plugin and Assets1:40
let's add it to the composer.json of our plugin so that it gets discovered. Let's add a new item to this array. So danharanFilamentToolkit and then AdminPanelProvider, which matches the name here. Finally, I'm just going to do a composer update in our app so that we can make sure the new ServiceProvider has been discovered. And now when we go back into the browser, here's our panel, but this time it's been registered from our plugin. Now you can install this plugin in a completely fresh Laravel app, and it will require all of the dependencies it needs to be able to render this panel. All the user has to do is run php artisan filament:assets to copy over the assets into their public directory. I'm sure by now some of you might have some ideas of some panels that you can redistribute in this way.
I'm sure by now some of you might have some ideas of some panels that you can redistribute in this way.
