Skip to content

Instantly share code, notes, and snippets.

@techhazard
Created December 8, 2014 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techhazard/b722549958b9cd519faa to your computer and use it in GitHub Desktop.
Save techhazard/b722549958b9cd519faa to your computer and use it in GitHub Desktop.
Laravel chaining reations?
I have several Models:
Course (id, line_id, category_id name...)
Category (id,name...)
Line (id, name...)
Semester (id, year_id, name...)
Year (id, study_id, name...)
Study (id,name...)
and 1 pivot table
course_semester.
I am already able to make an object/array of a course which contains:
course = {
id,
name,
...,
line = {
id,
name,
...
},
category = {
id,
name,
...
},
semesters = {
{id, name, ...},
{id, name, ...},
...
}
}
What I want to add in this object/array is:
study = {id, name, ...}
How would I do this?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment