当前位置: 首页>>代码示例>>PHP>>正文


PHP Course::join方法代码示例

本文整理汇总了PHP中app\Course::join方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::join方法的具体用法?PHP Course::join怎么用?PHP Course::join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Course的用法示例。


在下文中一共展示了Course::join方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getSortableCourses

 public function getSortableCourses($sort = 'name', $direction = 'asc')
 {
     if (!in_array($sort, ['name', 'par'])) {
         $sort = 'name';
     }
     return Course::join('holes', 'holes.course_id', '=', 'courses.id')->select('courses.slug', 'courses.name', DB::raw('sum(holes.par) as par'))->orderBy($sort, $direction)->groupBy('courses.id')->paginate(10);
 }
开发者ID:robeasdon,项目名称:golf-stat-tracker,代码行数:7,代码来源:CourseRepository.php

示例2: showCourseStatistics

 /**
  * @param Request $request
  * @param $code
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function showCourseStatistics(Request $request, $code)
 {
     if ($request->ajax()) {
         $courses = Course::join('semesters', 'courses.semester_id', '=', 'semesters.id')->join('teachers', 'courses.teacher_id', '=', 'teachers.id')->select('courses.code as Code', 'courses.name as Title', 'teachers.name as Teacher', 'semesters.name as Semester')->where('courses.department_code', '=', $code)->get();
         $unassignedCourses = Course::join('semesters', 'courses.semester_id', '=', 'semesters.id')->select('courses.code as Code', 'courses.name as Title', 'courses.teacher_id as Teacher', 'semesters.name as Semester')->where('courses.department_code', '=', $code)->whereNull('courses.teacher_id')->get();
         return response([$courses, $unassignedCourses]);
     }
 }
开发者ID:arnabrahman,项目名称:Course-and-Result-Management,代码行数:13,代码来源:DepartmentController.php

示例3: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($date, $area, $professorId = null)
 {
     if ($professorId == null) {
     }
     $insert_control = Insert_control::where('period', $date)->first();
     if ($insert_control == null) {
         $insert_control = 0;
     } else {
         $insert_control = $insert_control->available;
     }
     $userRole = Auth::user()->role()->first()->name;
     $dateExp = explode("-", $date);
     $year = $dateExp[0];
     $semester = $dateExp[1];
     $professor = Professor::find($professorId);
     $professorFromAreas = Area::where('name', $area)->first()->professors()->get();
     $arrayProfessors = array();
     foreach ($professorFromAreas as $professorFromArea) {
         $arrayProfessors[$professorFromArea->id] = $professorFromArea->name;
     }
     if (!isset($professor)) {
         $status = 1;
         $arrayProfessorss = $arrayProfessors;
         $arrayProfessorss[""] = "";
         return view('schedules.show', compact("status", "year", "semester", "arrayProfessorss"));
     }
     $todasAreas = Area::all()->toArray();
     $arrayAreas = array();
     foreach ($todasAreas as $unArea) {
         $arrayAreas[$unArea['id']] = $unArea['name'];
     }
     $professorLoad = 0;
     $arrayCourses = array();
     $areaCourses = Course::join('areas', 'areas.id', '=', 'courses.area_id')->where('areas.name', $area)->where('courses.year', $year)->where('courses.semester', $semester)->select('courses.id', 'courses.year', 'courses.semester', 'areas.name', 'courses.branch', 'courses.section', 'courses.code', 'courses.schedule')->get();
     $courseSelect = array();
     foreach ($areaCourses as $oneCourse) {
         if (count($oneCourse->schedule()->groupBy('professor_id')->get()) == 0) {
             $courseSelect[$oneCourse->id] = $oneCourse->code . "-" . $oneCourse->section . "-" . $oneCourse->year . "-" . $oneCourse->semester . " " . $oneCourse->branch . " (" . $oneCourse->schedule . ")";
         }
     }
     $schedules = Schedule::join('courses', 'courses.id', '=', 'schedules.course_id')->where('schedules.professor_id', $professorId)->where('courses.year', $year)->where('courses.semester', $semester)->get();
     foreach ($schedules as $schedule) {
         $course = array();
         $code = $schedule->course()->first()->code;
         $course['name'] = $schedule->course()->first()->name;
         $course['area'] = $arrayAreas[$schedule->course()->first()->area_id];
         $course['branch'] = $schedule->course()->first()->branch;
         $course['section'] = $schedule->course()->first()->section;
         $course['semester'] = $schedule->course()->first()->semester;
         $course['id'] = $schedule->course()->first()->id;
         $course['year'] = $schedule->course()->first()->year;
         $course['schedule'] = explode("-", $schedule->course()->first()->schedule);
         $course['code'] = $code;
         $arrayCourses[$code . "-" . $course['section']] = $course;
         // $professorLoad = $professorLoad + count($course['schedule'])*22.5;
         foreach ($course['schedule'] as $horario) {
             $array[$horario] = $course['code'] . "-" . $course['section'];
         }
     }
     $schedulesYear = Schedule::join('courses', 'courses.id', '=', 'schedules.course_id')->where('schedules.professor_id', $professorId)->where('courses.year', $year)->get();
     foreach ($schedulesYear as $sche) {
         $professorLoad = $professorLoad + count(explode("-", $sche->course()->first()->schedule)) * 22.5;
     }
     if ($semester == 1) {
         $nextSemester = 2;
         $nextYear = $year;
         $previewsYear = $year - 1;
     } else {
         $nextSemester = 1;
         $nextYear = $year + 1;
         $previewsYear = $year;
     }
     $nextDate = $nextYear . "-" . $nextSemester;
     $previewsDate = $previewsYear . "-" . $nextSemester;
     $urlAnterior = "schedules/{$previewsDate}/{$area}/{$professor->id}";
     $urlSiguiente = "schedules/{$nextDate}/{$area}/{$professor->id}";
     return view('schedules.show', compact('year', 'semester', 'urlAnterior', 'urlSiguiente', 'professor', 'courseSelect', 'arrayCourses', 'arrayProfessors', 'array', 'area', 'professorLoad', 'userRole', 'insert_control'));
 }
开发者ID:edmiranda,项目名称:uai_courses,代码行数:84,代码来源:ScheduleController.php

示例4: show

 /**
  * Using this method for two different AJAX request. One for enroll course & one for save result
  *
  * Display the specified resource.
  *
  * @param Request $request
  * @param $id
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function show(Request $request, $id)
 {
     if ($request->ajax()) {
         $studentInfo = Student::join('departments', 'students.department_code', '=', 'departments.code')->select('students.name', 'students.email', 'students.department_code', 'departments.name as department')->where('students.registration_no', '=', $id)->first();
         if ($request->has('grade')) {
             /**
              * Select courses of a student which is not being graded
              * @var TYPE_NAME $courses
              */
             $courses = Course::join('course_student', 'courses.code', '=', 'course_student.course_code')->select('courses.code', 'courses.name')->where('course_student.student_registration_no', $id)->where(function ($query) {
                 $query->whereNull('course_student.grade')->orWhere('course_student.grade', '');
             })->get();
         } elseif ($request->has('result')) {
             $student = Student::find($id);
             /** Check whether user can see the result
              * @var TYPE_NAME $this */
             $this->authorize('viewResult', $student);
             $courses = Course::join('course_student', 'courses.code', '=', 'course_student.course_code')->select('courses.code', 'courses.name', 'course_student.grade')->where('course_student.student_registration_no', $id)->get();
         } else {
             $courses = Course::select('courses.code', 'courses.name')->where('courses.department_code', '=', $studentInfo->department_code)->whereNotIn('courses.code', function ($query) use($id) {
                 $query->select('course_student.course_code')->from('course_student')->where('course_student.student_registration_no', '=', $id);
             })->get();
         }
         return response([$studentInfo, $courses]);
     }
 }
开发者ID:arnabrahman,项目名称:Course-and-Result-Management,代码行数:35,代码来源:StudentController.php


注:本文中的app\Course::join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。