There are two types of relationships between CRUDs in our system:

  • BelongsTo (1-to-many)
  • BelongsToMany (many-to-many)

To create a relationship, you need to create a "parent" CRUD first, and then, while creating a "child" CRUD, choose a field type called BelongsTo Relationship.

CRUD Relationships

QuickAdminPanel will generate a lot of things automatically for you. The most important settings are at the bottom of the screenshot above:

  • Relationship model: choose the "parent" CRUD for belongsTo function
  • Field to show in list: what parent field should be shown in your current "child" CRUDs list table (usually something like "name" or "title")
  • Additional fields: related to above, you can show more fields in the table if you want. Every field would take its own table column.
  • Allow to create entries while creating parent entry: this checkbox means that in the parent CRUD create page system would generate additional form to create child entries, too. Read more here.

You don't need to create any additional fields, methods or settings. QuickAdminPanel will automatically create a field [yourfield]_id, foreign key in migrations and model function with $this->belongsTo() relationship.