On this page
Config File
first, provide an array in your config file, contain the model class name as a key, and its value will be the full path: For example, let say you plugin needs two models, the user model and a Bookmark model:
1/**2 * you can overwrite any model and use your own3 * you can also configure the model per panel in your panel provider4 * using: ->models([ ... ])5 */6'models' => [7 'User' => config('auth.providers.users.model'),8 'Bookmark' => \LaraZeus\Delia\Models\Bookmark::class,9],
This way, your users can configure the models per panel or globally from the config file:
1public function panel(Panel $panel): Panel 2{ 3 return $panel 4 // ... 5 ->plugins([ 6 MyAwesomePlugin::make() 7 ->models([ 8 'User' => \App\Models\Manager::class 9 ]),10 ]);11}
with this approach, FilamentPluginTools
will merge the models from the config file, and what the user provide per panel.
now, in your plugin, you can use it like:
1MyAwesomePlugin::getModel('User')