I was reading Laravel docs about defining relationships and it all was a bit unclear to me. (could because of language barrier.. )
I got the following:
I want people to choose an objective. If user chooses a objective, the related packages show up. In these packages there is a info button, containing further info about the package. If user clicks on the info link, the related package info will show up.
FYI! There will be 9 objectives. Each objective has 3 packages and each package has 1 packageinfo.
Objective Model
// contains
- id
- name
- icon
// relationship
HasMany package
////////////////////////////////////////////////////
Package Model
// contains
- id
- title
- information
- info_link
- buy_link
// relationship
belongsToMany Model
hasMany PackageInfo -- or has PackageInfo ?
///////////////////////////////////////////////////
PackageInfo Model
// contains
- id
- body
// relationship
belongsToMany Package -- or belongsTo Package ?
//////////////////////////////////////////////////
Objective_package Pivot
- id
- Objective_id
- Package_id
package_packageInfo pivot
- id
- Package_id
- packageinfo_id
Am i defining the relationships correct or did i really read the whole doc like upside-down?