[ 'first_name' => 10, 'surnames' => 10, 'email' => 2, ], ]; public function scopeFromSchool($query, $school_id) { return $query->join('program_user', 'program_user.user_id', '=', 'users.id') ->join('programs', 'program_user.program_id', '=', 'programs.id') ->where('programs.school_id', $school_id) ->select('users.*'); } public function scoreFromPrograms($query, $program_ids) { return $query->join("program_user", 'users.id', '=', 'program_user.user_id') ->whereIn('program_user.program_id', $program_ids) ->select('users.*'); } public function program() { return $this->belongsTo('Program'); } public function school() { return $this->belongsTo('School'); } public function courses() { return $this->hasMany('Course')->whereIn('semester_id', Session::get('semesters_ids'))->orderBy('code')->orderBy('number')->orderBy('section')->orderBy('semester_id'); } public function rubrics() { return $this->hasMany('Rubric')->orderBy('name'); } // return the programs the user is a pcoord of public function programs() { return $this->belongsToMany('Program')->select('programs.id', 'programs.name', 'programs.school_id', 'programs.is_graduate'); } }