本文整理匯總了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'));
}