本文整理汇总了PHP中app\Course::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::orderBy方法的具体用法?PHP Course::orderBy怎么用?PHP Course::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Course
的用法示例。
在下文中一共展示了Course::orderBy方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: all
public function all()
{
$breadcrumbs = array(action('HomeController@show') => 'Início', action('CourseController@all') => 'Todos os cursos');
$previous = action('HomeController@show');
$courses = Course::orderBy('name')->get();
return view('all-courses', compact('breadcrumbs', 'previous', 'courses'));
}
示例2: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$teacher = User::find(Auth::user()->id);
$resourceTypes = Resource_type::all();
$courses = $crs = Course::orderBy('affiliateId', 'DESC')->orderBy('streamId', 'DESC')->orderBy('levelId', 'DESC')->get();
return view('teacher')->with('teacher', $teacher)->with('resourceTypes', $resourceTypes)->with('courses', $courses);
}
示例3: courses
public function courses()
{
$courses = Course::orderBy('created_at', 'desc')->get();
$return_data = [];
foreach ($courses as $course) {
$return_data[] = ["id" => $course->id, "linkId" => convert_vi_to_en($course->name), 'name' => "Khoá học " . $course->name, "icon_url" => $course->icon_url, "description" => $course->description, "avatar_url" => $course->image_url, "price" => currency_vnd_format($course->price)];
}
return $this->respond($return_data);
}
示例4: index
public function index(Request $request)
{
// 获取排序条件
$orderColumn = $request->get('sort_up', $request->get('sort_down', 'created_at'));
$direction = $request->get('sort_up') ? 'asc' : 'desc';
$courses = Course::orderBy($orderColumn, $direction)->paginate(8);
$stores = json_encode(DB::table('stores')->where('deleted_at', null)->select('id', 'name')->get());
$coaches = json_encode(DB::table('coaches')->where('deleted_at', null)->select('id', 'name')->get());
return view('admin.course.list', compact('courses', 'stores', 'classrooms', 'coaches', 'query'));
}
示例5: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$student = Auth::user();
$regs = Registration::where('student_id', '=', $student->id)->get();
if (count($regs) > 0) {
Flash::error('You have completed registration!.');
return redirect()->route('registration.index');
}
$courses = Course::orderBy('name')->lists('name', 'id');
return view('reg.create', compact('courses'));
}
示例6: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$courses = Course::orderBy('name')->get();
foreach ($courses as $course) {
$user = User::where('id', '=', $course->lecturer_id)->firstOrFail();
$course['lecturer_name'] = $user->name;
$dept = Department::where('id', '=', $course->department_id)->firstOrFail();
$course['department_name'] = $dept->name;
}
return view('course.index', compact('courses'));
}
示例7: index
public function index(Request $request)
{
$courses = [];
try {
$title = $request->all()['title'];
$subject = $request->all()['subject'];
$number = $request->all()['number'];
$courses = Course::where('title', 'like', '%' . $title . '%')->where('subject_code', 'like', '%' . $subject . '%')->where('number', 'like', '%' . $number . '%')->orderBy('subject_code')->orderBy('number')->paginate(10);
} catch (\ErrorException $e) {
$courses = Course::orderBy('subject_code')->orderBy('number')->paginate(25);
}
return view('courses.index')->with('courses', $courses);
}
示例8: listAllCourses
public function listAllCourses()
{
return Course::orderBy('name', 'asc')->lists('name', 'id');
}
示例9: index
public function index()
{
$courses = Course::orderBy('importance', 'desc')->get();
return view('resume.courses', compact('courses'));
}
示例10: index
/**
* Display the landing page of the application.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$newCourses = Course::orderBy('created_at', 'desc')->take(2)->get();
$poularCourses = DB::table('courses')->leftjoin('user_course', 'courses.id', '=', 'user_course.course_id')->join('users', 'user_course.user_id', '=', 'users.id')->groupBy('courses.id')->take(2)->get();
return view('public.home')->with('newCourses', $newCourses)->with('popularCourses', $poularCourses);
}
示例11: courses
public function courses()
{
$courses = Course::orderBy('created_at', 'desc')->get();
return response()->json(['courses' => $courses]);
}
示例12: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit()
{
$organization = Organization::where('userId', Auth::user()->id)->first();
$crs = Course::orderBy('affiliateId', 'DESC')->orderBy('streamId', 'DESC')->orderBy('levelId', 'DESC')->get();
return view('organization.edit')->with('organization', $organization)->with('courses', $crs);
}
示例13: adminIndex
/**
* Display a listing of the resource.
*
* @return Response
*/
public function adminIndex()
{
$courses = Course::orderBy('day')->with(['manager', 'instrument', 'article', 'documents', 'users' => function ($query) {
$query->where('level', 0)->where('validated', 1)->orderBy('last_name');
}, 'teachers' => function ($query) {
$query->where('level', 1)->where('validated', 1)->orderBy('last_name');
}])->paginate(20);
return view('admin.courses.index', compact('courses'));
}
示例14: function
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::group(['middleware' => ['web']], function () {
/**
* List all courses
*/
Route::get('/', function () {
$courses = Course::orderBy('created_at', 'asc')->get();
return view('courses', ['courses' => $courses]);
});
/**
* Add a course
*/
Route::post('/course', function (Request $request) {
$validator = Validator::make($request->all(), ['name' => 'required|max:255', 'date' => 'required']);
if ($validator->fails()) {
return redirect('/')->withInput()->withErrors($validator);
}
$course = new Course();
$course->name = $request->name;
$course->date = $request->date;
$course->save();
return redirect('/');