本文整理汇总了PHP中Course::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::with方法的具体用法?PHP Course::with怎么用?PHP Course::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course::with方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create($course_id)
{
$course = Course::with('placements')->find($course_id);
$subjects = Subject::all();
$menu = 'academic';
return View::make('masteries.create', compact('course', 'subjects', 'menu'));
}
示例2: create
public function create($course_id)
{
$course = Course::with('placements')->find($course_id);
$employees = Employee::where('teach_salary', '>', 0.0)->get();
$hours = Hour::all();
$menu = 'academic';
return View::make('presences.create', compact('course', 'subjects', 'employees', 'hours', 'menu'));
}
示例3: destroy
public function destroy($id)
{
$course = Course::with('placements')->find($id);
if ($course->placements->count() > 0) {
Session::flash('message', 'Tidak dapat menghapus data Kelas! Kelas ini pernah digunakan!');
} else {
Course::destroy($id);
Session::flash('message', 'Sukses menghapus data Kelas!');
}
}
示例4: exporttCourseAttendenceToCSV
/**
* Exports the total amount of students that are taking each course to a CSV file
*/
public function exporttCourseAttendenceToCSV()
{
$course_data = Course::with('students')->get();
$csv = \League\Csv\Writer::createFromFileObject(new \SplTempFileObject());
$column_flag = false;
$course_listing = [];
foreach ($course_data as $course) {
$course_listing['course_name'] = $course->course_name;
$course_listing['num_students'] = count($course->students);
//Check whether column headers have been set (not ideal for large datasets)
if ($column_flag === false) {
$csv->insertOne(\Schema::getColumnListing('course_listing'));
$column_flag = true;
}
$csv->insertOne($course_listing);
}
$csv->output('course_attendance_records.csv');
}
示例5: recapCourse
public function recapCourse()
{
$courses = Course::where('project_id', '=', Auth::user()->curr_project_id)->get();
$periods = DB::table('registrations')->select(DB::raw('month(registration_date) as months'), DB::raw('year(registration_date) as years'))->groupBy(DB::raw('month(registration_date)'))->get();
$courselists = array();
foreach ($courses as $course) {
$statistics = array();
foreach ($periods as $period) {
$count = Course::with(array('placements', 'placements.issues.registration'))->join('placements', 'placements.course_id', '=', 'courses.id')->join('issues', 'issues.id', '=', 'placements.issue_id')->join('registrations', 'registrations.id', '=', 'issues.registration_id')->where(DB::raw('month(registrations.registration_date)'), '=', $period->months)->where(DB::raw('year(registrations.registration_date)'), '=', $period->years)->where('courses.id', '=', $course->id)->count();
$statistics[] = array('count' => $count);
}
$courselists[] = array('id' => $course->id, 'name' => $course->name, 'statistics' => $statistics);
}
$menu = 'report';
return View::make('reports.recapcourse', compact('periods', 'courselists', 'menu'));
}