本文整理汇总了PHP中app\Course::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::with方法的具体用法?PHP Course::with怎么用?PHP Course::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Course
的用法示例。
在下文中一共展示了Course::with方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
\View::composer('*', function ($view) {
$allCourses = \App\Course::with('requirements')->orderBy('course_name', 'ASC')->get()->toArray();
$view->with('user', \Auth::user())->with('allCourses', $allCourses);
});
}
示例2: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index($semester = null, $year = null)
{
$user = Auth::user();
$split = explode(" ", $user->role->name);
$role_area = $split[count($split) - 1];
$areas = Area::with('professors')->get()->toArray();
$profe = Professor::with('areas')->get()->toArray();
$prof_areas = array();
foreach ($profe as $prof) {
$prof_areas[$prof['id']] = $prof['areas'];
}
$collection = collect($areas);
$area_professors = $collection->keyBy('name')->toArray();
// TODO: Pasar esto a un Helper
if ($semester == null) {
\Carbon\Carbon::now()->month >= 5 ? $semester = 2 : ($semester = 1);
}
$year == null ? $year = \Carbon\Carbon::now()->year : ($year = $year);
$courses = Course::with('area')->get()->toArray();
if ($role_area == "Administrador") {
$professors = Professor::all()->toArray();
//TODO: Pasar esto a un scope
$unasigned_courses = Course::with('area')->where('taken', 0)->where('semester', $semester)->where('year', $year)->get();
$asigned_courses = Course::with('area')->where('taken', 1)->where('semester', $semester)->where('year', $year)->get();
} else {
$professors = Area::with('professors')->where('name', $role_area)->get()->toArray()[0]["professors"];
$area = Area::where('name', $role_area)->first();
$unasigned_courses = Course::where('taken', 0)->where('area_id', $area->id)->where('semester', $semester)->where('year', $year)->get();
$asigned_courses = Course::where('taken', 1)->where('area_id', $area->id)->where('semester', $semester)->where('year', $year)->get();
}
$professorCourse = array();
foreach ($courses as $course) {
if (Schedule::where('course_id', $course['id'])->first() != null) {
$professorId = Schedule::where('course_id', $course['id'])->first()->professor_id;
$professorCourse[$course['id']] = Professor::where('id', $professorId)->first()->name;
}
}
return view('schedules.index', compact('area_professors', 'prof_areas', 'professors', 'courses', 'professorCourse', 'unasigned_courses', 'asigned_courses', 'year', 'semester'));
}
示例3: getCourse
public function getCourse()
{
$course = Course::with('course_id', $this->course_id);
return $course;
}
示例4: getAllCourses
public function getAllCourses()
{
return Course::with('holes.tees', 'teeSets.teeType', 'teeSets.tees')->get();
}
示例5: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$course = Course::with('tests', 'tests.questions')->has('tests.questions', '>', 0)->published()->findOrFail($id);
return view('course.show', ['course' => $course]);
}
示例6: getRecord
public function getRecord($id)
{
return Course::with('college')->find($id);
}
示例7: getCourses
public function getCourses()
{
$courses = Course::with('college')->get();
return view('admin.coursesList', compact('courses'));
}
示例8: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$courses = Course::with('area')->get();
return view('courses.index', compact('courses'));
}
示例9: documentsValidated
public function documentsValidated($id, $value)
{
$course = Course::with(['users' => function ($query) {
$query->where('level', 1);
}, 'manager'])->find($id);
if (empty($course)) {
Flash::error('Ce cours n\'existe pas.');
return abort(404);
}
if (Auth::user()->level_id <= 3 && !$course->users->contains(Auth::user())) {
Flash::error('Vous n\'avez pas les droits suffisants.');
return Redirect::back();
}
if ($value != 0 && $value != 1) {
Flash::error('Requête invalide.');
return Redirect::back();
}
$documents = Document::where('course_id', $id)->where('validated', $value)->with('author')->paginate(15);
$filter = $value == 0 ? 'invalidés' : 'validés';
return view('admin.courses.documents', compact('documents', 'filter', 'course'));
}
示例10: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$course = Course::with('tests', 'tests.questions', 'tests.questions.answers')->findOrFail($id);
foreach ($course->tests as $test) {
foreach ($test->questions as $question) {
foreach ($question->answers as $answer) {
$answer->delete();
}
$question->delete();
}
$test->delete();
}
$course->delete();
}