Monday, April 10, 2017

Eloquent ORM with multiple models

I'm trying to create a new web application, currently I have created a static array with some information which looks like this:

static array

Also I have models like this:

  • User
  • School
  • Grade
  • Lesson

Lessons table has school_id foreign key.

School table has admin_id foreign key.

Grades table has lesson_id, teacher_id, user_id foreign keys.

I'm having troubles generating a dynamic array like I showed before. I tried using

->with('grades')->with('lessons')

but it didn't do anything like I wanted to.

Maybe someone can give me some directions?



via Ventilaator

Advertisement