The correct way to do this is
SCHOOL
public function classes()
{
return $this->hasMany('App\Class');
}
public function users()
{
return $this->hasMany('App\User');
}
public function events()
{
return $this->hasMany('App\Event');
}
CLASS
public function school()
{
return $this->belongsTo('App\School');
}
public function subjects()
{
return $this->hasMany('App\Subject');
}
public function homeworks()
{
return $this->hasMany('App\Homework');
}
public function users()
{
return $this->belongsToMany('App\User','class_users','class_id','user_id');
// this should be many to many because users can also have many classes
}
USER
public function school()
{
return $this->belongsTo('App\School');
}
public function classes()
{
return $this->belongsToMany('App\Class','class_users','user_id','class_id');
// this should be many to many as explained to class
}
public function sessions()
{
return $this->belongsToMany('App\Session','session_users','user_id','session_id');
// like classes do, this should be many to many relationship because sessions can also have many users
}
SUBJECT
public function class()
{
return $this->belongsTo('App\Class');
}
SESSION
public function users()
{
return $this->belongsToMany('App\User','session_users','session_id','user_id');
// should be many to many as well
}
public function cases()
{
return $this->hasMany('App\Case');
}
CASE
public function session()
{
return $this->belongsTo('App\Session');
}
EVENT
public function school()
{
return $this->belongsTo('App\School');
}
HOMEWORK
public function class()
{
return $this->belongsTo('App\Class');
}