本文整理汇总了PHP中app\Course::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::where方法的具体用法?PHP Course::where怎么用?PHP Course::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Course
的用法示例。
在下文中一共展示了Course::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Show the application dashboard.
*
* @return Response
*/
public function index()
{
// Get an array of courses which this instructor has created
$courses = Course::where('instructor_id', '=', Auth::id())->get();
// Render the view, passing the courses array into it
return view('home')->with('courses', $courses);
}
示例2: show
public function show($slug)
{
$course = Course::where('slug', $slug)->firstOrFail();
$breadcrumbs = array(action('HomeController@show') => 'Início', action('CourseController@all') => 'Cursos', action('CourseController@show', $slug) => $course->name);
$previous = action('CourseController@all');
return view('course', compact('breadcrumbs', 'previous', 'course'));
}
示例3: new_courses
public function new_courses()
{
Course::where('offered_this_semester', true)->update(['offered_this_semester' => false]);
$courseSeeder = new \CourseTableSeeder();
$courseSeeder->run();
return redirect(route('course.index'));
}
示例4: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create($course_url, $stage_url)
{
$curso = Course::where('url', $course_url)->first();
$etapa = Stage::where('url', $stage_url)->where('course_id', $curso->id)->first();
$tiposItem = ItemType::all()->pluck('name', 'id');
return view('pages.items.create', ['curso' => $curso, 'etapa' => $etapa, 'tiposItem' => $tiposItem]);
}
示例5: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($course_url, $stage_url, $url)
{
$curso = Course::where('url', $course_url)->first();
$etapa = Stage::where('url', $stage_url)->first();
$item = Item::where('url', $url)->first();
$tiposItem = ItemType::all()->pluck('name', 'id');
return view('pages.items.edit', ['curso' => $curso, 'etapa' => $etapa, 'item' => $item, 'tiposItem' => $tiposItem]);
}
示例6: getCourseInCategory
public function getCourseInCategory($category_slug, $course_slug)
{
$category = Category::where('slug', $category_slug)->first();
// find id of slug
$matchThese = ['category_id' => $category->id, 'slug' => $course_slug];
$course = Course::where($matchThese)->first();
return view('courses.show')->with('course', $course);
}
示例7: getRemoved
public function getRemoved($crn)
{
$course_id = \App\Course::where('crn', '=', $crn)->first()->id;
$user = \Auth::user();
$user->courses()->detach($course_id);
\Session::flash('flash_message', 'The course was removed from your list!');
return redirect()->back();
}
示例8: showElectiveSelectionView
public function showElectiveSelectionView()
{
// Get electives
$electives = Course::where('dCode', Auth::guard('teacher')->user()->dCode)->where(function ($q) {
$q->where('openElective', true)->orWhere('departmentElective', true);
})->get();
return view($this->electiveSelectionView, ['electives' => $electives]);
}
示例9: manageCourses
/**
* Show courses currently present in database
*
* @return mixed
*/
public function manageCourses()
{
// Get the list of courses
$courses = Course::where('dCode', Auth::guard('departmentStaff')->user()->dCode)->orderBy('semNo', 'asc')->paginate(8);
// Department code
$dCode = Auth::guard('departmentStaff')->user()->dCode;
return view($this->courseManagementView, ['courses' => $courses, 'count' => 0, 'dCode' => $dCode]);
}
示例10: addAcademics
protected function addAcademics()
{
// Academic details.
$this->add('college_id', 'entity', ['label' => 'College', 'class' => 'App\\College', 'selected' => College::where('name', 'None')->value('id')])->add('course_id', 'entity', ['label' => 'Course', 'class' => 'App\\Course', 'property' => 'course_with_type', 'query_builder' => function ($obj) {
return $obj::get();
}, 'selected' => Course::where('name', 'None')->value('id')])->add('start_year', 'number', ['label' => 'Matriculation year', 'default_value' => Carbon::today()->year])->add('end_year', 'number', ['label' => 'Graduation year (estimated)', 'default_value' => Carbon::today()->year + 3]);
return $this;
}
示例11: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//course is determined by the button pushed in the courses index page
$course = Course::where('course_id', $id)->lists('course_name', 'course_id');
//user role must be 3, meaning this retrieves a student list with no admins/instructors
$users = User::where('user_role', 3)->lists('user_name', 'user_id');
return view('courses.rosters')->with('course', $course)->with('users', $users);
}
示例12: __construct
/**
* Create a new user controller instance.
*
* @return void
*/
public function __construct()
{
$this->priviledge_user();
$this->_user = \Auth::user();
if (2 == $this->_user->role_id) {
$this->_query_connect = "=";
$this->_query_value = $this->_user->department_id;
}
$this->_plan_courses = Course::where('department_id', $this->_query_connect, $this->_query_value)->lists('name', 'id');
$this->_plan_curriculums = Curriculum::lists('name', 'id');
}
示例13: getByUniversity
public function getByUniversity($code)
{
$university = Course::where('university_code', $code)->get();
$validator = Validator::make(array('code' => $code), array('code' => array('required', 'regex:/(?i)^[a-z]+/')));
if ($validator->fails()) {
return response()->json(['error' => true, 'description' => 'only alphabets are allowed']);
}
if ($university == null) {
return response()->json(['error' => true, 'description' => 'code is not valid']);
}
return response()->json(['error' => false, 'topic' => $university]);
}
示例14: showCourseManagementView
/**
* Show courses currently taught by teacher
*
* @return mixed
*/
public function showCourseManagementView()
{
// Get the courses teacher is teaching
$teacherCourses = Auth::guard('teacher')->user()->teachingDetails;
$teacherCourseCodes = [];
foreach ($teacherCourses as $teacherCourse) {
array_push($teacherCourseCodes, $teacherCourse->courseCode);
}
// Get a list of all courses
$courses = Course::where('dCode', Auth::guard('teacher')->user()->dCode)->whereNotIn('courseCode', $teacherCourseCodes)->get();
return view($this->courseView, ['teacherCourses' => $teacherCourses, 'courses' => $courses]);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
do {
$videoCode = self::VIDEO_PRE_CODE . StringUtil::getRandomString();
$courses = Course::where('video_code', $videoCode)->first();
if (empty($courses)) {
$request['video_code'] = $videoCode;
break;
}
} while (true);
return $next($request);
}