Tree structured models
A child admin model is attached to its parent with$belongsToModel. The parent form then shows a nested module for the child records, and the foreign keys and relations are created automatically.
app/Models/OrdersItem.php
Relations in a field
Two independent modules, each in its own place in the administration, are linked through fields. A record is linked to one record of another table withbelongsTo, or to several records with belongsToMany.
app/Models/Article.php
Selecting related records
Laravel requires relationship methods on the model to select related records. CrudAdmin maps the models to each other based on the fields and the tree structure, so you do not have to write these methods. Defining your own relations in the model is still possible when you need it.Selecting a relation in a tree structure
This example works with an order that contains several ordered items.app/Models/Order.php
app/Models/OrdersItem.php
Selecting a relation assigned in a field
app/Models/Article.php