public static function getUserSchoolByUser($user) { // $profile= ; // $classId = DB::table('teachingclasses')->where('users_id', $user->id)->value('classes_id'); // $schoolId = DB::table('classes')->where('classes_id', $classId)->value('schools_id'); // $schoolName = DB::table('schools')->where('id', $schoolId)->value('name'); $sectionId = User::find($user->id)->teachingSection()->first()->value('sections_id'); $section = Section::getSectionByUser($user); $school = Section::find($sectionId)->school(); $section = Section::find($sectionId); // $profile = []; return $school; }