Seiten · Laravilt
Creating a Plugin
Build a plugin with a model, migration and resource, then register it on a panel.
This guide builds a blog-manager plugin with a Post resource.
Step 1: Generate the scaffold
bash
Select at least:
- Laravilt plugin
- Database migrations
- Language files
The plugin is created in packages/laravilt/blog-manager.
Step 2: Load it in your app
In your application's composer.json:
json
bash
Step 3: Generate components
bash
Edit the migration, add $fillable to the model, and point PostResource::getModel() to Laravilt\BlogManager\Models\Post. Then run:
bash
Step 4: Write the plugin class
php
Migrations and translations are loaded by the generated BlogManagerServiceProvider.
Step 5: Register the plugin
php
Open the panel and the Posts resource appears in the navigation.