本文整理汇总了PHP中app\Course::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::find方法的具体用法?PHP Course::find怎么用?PHP Course::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Course
的用法示例。
在下文中一共展示了Course::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: signToAllStripesForCourse
public function signToAllStripesForCourse($id)
{
$course = Course::find($id);
foreach ($course->stripes as $stripe) {
$this->stripes()->attach($stripe);
}
}
示例2: destroy
public function destroy($id)
{
$courses = Course::find($id);
$courses->schedules()->delete();
$courses->delete();
return response()->json(['id' => $id]);
}
示例3: getUnavailableGpAsgs
public function getUnavailableGpAsgs($courseId)
{
$gpAsgs = Course::find($courseId)->gpAsgs;
return $gpAsgs->filter(function ($gpAsg) {
return !$this->testGpAsgAvailable($gpAsg);
});
}
示例4: getUnavailableWithinGpAsgs
public function getUnavailableWithinGpAsgs($courseId)
{
$withinGpAsgs = Course::find($courseId)->withinGpAsgs;
return $withinGpAsgs->filter(function ($withinGpAsg) {
return !$this->testWithinGpAsgAvailable($withinGpAsg);
});
}
示例5: show
public function show($course_id)
{
$course = Course::find($course_id);
if ($course) {
return $this->createSuccessResponse($course, 200);
}
return $this->createErrorResponse("The course with id {$course_id} does not exists", 404);
}
示例6: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($course_id)
{
if (Auth::user()->isProfessor()) {
return view('professors.courses.show', ['class' => Course::find($course_id)]);
} else {
return view('students.courses.show');
}
}
示例7: lessons
public function lessons($domain, $courseId)
{
$course = Course::find($courseId);
if (!$course) {
return response()->json(['error' => "Môn học không tồn tại"], 404);
}
$lessons = Lesson::where('course_id', $courseId)->get();
return response()->json(['course' => ['id' => $course->id, 'name' => $course->name, 'avatar_url' => $course->icon_url], 'lessons' => $lessons]);
}
示例8: update
/**
* Actualiza un curso por su ID
*
* @param Request
* @param Int id
*/
public function update(CourseRequest $request, $id)
{
$name = $request->name;
$url = UrlSanitizer::sanitize($name);
$request["url"] = $url;
$curso = Course::find($id);
$curso->update($request->all());
return redirect()->route('courses.index');
}
示例9: updateCourse
public function updateCourse(UpdateCourseRequest $req)
{
$course = Course::find($req->id);
$course->abrr = $req->abrr;
$course->name = $req->name;
$course->college = $req->college;
$course->status = $req->status;
$course->save();
}
示例10: destroy
public function destroy($id)
{
$course = Course::find($id);
/* $sections = $grade->sections;
if ($sections->count() > 0)
return back()->with('error', 'No es posible eliminar un curso asociado a secciones.');
*/
$course->delete();
return back();
}
示例11: destroy
public function destroy($teacher_id, $course_id)
{
$teacher = Teacher::find($teacher_id);
if ($teacher) {
$course = Course::find($course_id);
if ($course) {
$course->delete();
return $this->createSuccessResponse("The course with id {$course->id} has been deleted.", 200);
}
return $this->createErrorMessage("The course with the specified id does not exists.", 404);
}
return $this->createErrorMessage("The teacher with id {$teacher_id} does not exists.", 404);
}
示例12: update
public function update($courseId)
{
$request = json_decode(request()->getContent());
$rules = array('name' => 'required', 'attendants' => 'required');
$validation = Validator::make((array) $request, $rules);
if ($validation->fails()) {
return response()->json(array('error' => true, 'message' => $validation->errors()->all(), 200));
}
$course = Course::find($courseId);
$course->name = $request->name;
$course->attendants = abs($request->attendants);
$updated = $course->save();
return response()->json(array('error' => !$updated, 'courses' => $course->toArray()), $updated ? 200 : 500);
}
示例13: destroy
public function destroy($handbook_id, $course_id, $grade_id)
{
$course = Course::find($course_id);
// If the course is already associated
$relationExist = CourseGrade::where('course_handbook_id', $handbook_id)->where('course_id', $course_id)->where('grade_id', $grade_id)->first();
if ($relationExist) {
$relationExist->delete();
$message = "Se ha eliminado correctamente el curso del grado.";
$type = "success";
return back()->with(compact(['message', 'type']));
}
$message = "El curso no se encuentra asignado al grado.";
$type = "warning";
return back()->with(compact(['message', 'type']));
}
示例14: IN
function view_curriculum($id)
{
$get_cur = DB::select("SELECT `id`,code, descriptivetitle FROM tbl_subject\n WHERE tbl_subject.id NOT IN (SELECT subject FROM tbl_curriculumdetail WHERE curriculum = '{$id}')\n ORDER BY code ASC,descriptivetitle ASC");
$cur_detail = DB::table('tbl_curriculumdetail')->where('curriculum', $id)->orderBy('yearlevel', 'ASC')->orderBy('term', 'ASC')->groupBy('yearlevel')->groupBy('term')->get();
$cur = DB::table('tbl_curriculum')->where('id', $id)->first();
$cm = DB::table('tbl_coursemajor')->where('id', $cur->coursemajor)->first();
$c = Course::find($cm->course);
$m = '';
if ($cm->major != 0) {
$m = DB::table('tbl_major')->where('id', $cm->major)->first();
$major = $m->description;
}
$course = $c->description . ' ' . $m;
return view('dean.view_curriculum', compact('get_cur', 'cur_detail', 'cur', 'id', 'course'));
}
示例15: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$course = Course::find($this->courses);
switch ($this->method()) {
case 'GET':
case 'DELETE':
return [];
case 'POST':
return ['department_id' => 'integer|min:1', 'code' => 'required|unique:courses|max:20', 'name' => 'required|max:254'];
case 'PUT':
case 'PATCH':
return ['department_id' => 'integer|min:1', 'code' => "required|unique:courses,code,{$course->id}|max:20", 'name' => 'required|max:254'];
default:
break;
}
}