This short tutorial demonstrates that in Skipper, import of an existing Laravel Eloquent project and the following model editing is simple and intuitive.
Hint: See the ORM Model basics for a detailed description of ORM elements (e.g. bundle, entity).
At first, we will import demo project to Laravel Eloquent Skipper project (Skipper supports only database import for Eloquent projects). To do this, select Import External Model from File menu and follow the steps shown in the pictures below.
The last screen visually represents Demo project imported to Skipper and arranged automatically by import algorithm. It is a good starting point to work with your model.
Arrange visual model
Although the imported model is automatically arranged, it is a good idea to reposition entities inside the bundles to exactly fit the model logic. Also, you can change colors of bundles according to your preferences.
Extend project model
Now we have nice visual model. Let’s extend it to store categories for product entities. We add Category entity, configure new fields and create association between Category and Product entity.
When we finished the application model editing, the next step is to export it to Laravel Eloquent model migrations, model base classes and derived model classes. Model classes are exported in accordance with their namespaces to corresponding directories (based on PSR-4). Migrations are exported to \database\migrations directory which can be changed/configured for each module via ORM Properties.
Skipper exports base model object and derived model object for each Laravel Eloquent entity and one migration file for each defined migration in the application. Base model objects and migrations are updated during every export, but derived model objects are exported only once because they serves for defining user logic.
Before the first export we create our initial migration (revision), as shown in picture 2 below this section. After that, we export the whole project to a target directory. In our case, the project will export four schema model base classes, four derived classes and one migration file.
Tip: Each bundle might have its own export path which is relative to a project root directory.
And here is a full example of Customer entity. As you can see everything is well formatted and defined by Laravel Eloquent coding rules.
Next time you will need to make further changes or adjust the model, just open Skipper file and edit your project entities. Then again export the project to model classes and migrations.
As you can see above, import, editing and export to schema definition files is a five minute work with Skipper (ten if you are doing it for the first time). Now compare it with the effort of doing such task manually. As you have just discovered, Skipper dramatically saves your time and helps you work with schema definitions in much more enjoyable way.