orbit
orbit copied to clipboard
Add ability to create dynamic schema for Model
Make Orbit able to create schema outside the model class.
Orbit::registerDynamicSchema('posts', function (Blueprint $table) {
$table->string('external_url')->nullable();
});
This will add external_url column to the posts table.
@phuclh How exactly would you use this?
@ryangjchandler My use case is I have a blog platform and some users want to write their plugins for the blog. One of the plugins requires adding new columns to the Post model. Of course, they cannot add it in the schema method in the Post model since it lives in the core. That was why I came up with this PR.
Hi @ryangjchandler, do you think you can merge this PR? Thank you!
@phuclh I feel like a nicer API might be registering the custom schema on the model itself, no? Something like Post::registerDynamicSchema()?