当前位置: 首页>>代码示例>>PHP>>正文


PHP Student::orderBy方法代码示例

本文整理汇总了PHP中app\Student::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::orderBy方法的具体用法?PHP Student::orderBy怎么用?PHP Student::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Student的用法示例。


在下文中一共展示了Student::orderBy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createQuery

 /**
  * @param StudentSearch $request
  * @return mixed
  */
 private function createQuery(StudentSearch $request)
 {
     if (!$this->search->createQuery($request->all())) {
         return Student::orderBy('last_name', 'ASC')->paginate(10);
     }
     return $this->search->createQuery($request->all())->paginate(10);
 }
开发者ID:arielmagbanua,项目名称:sis_test,代码行数:11,代码来源:ReportsController.php

示例2: createQuery

 public function createQuery($request)
 {
     $first_name = $request['first_name'];
     $last_name = $request['last_name'];
     $year = $request['year'];
     $section = $request['section'];
     $city = $request['city'];
     $age = $request['age'];
     $zip = $request['zip'];
     if ($zip || $first_name || $last_name || $year || $section || $city || array_key_exists($age, config('student.brackets'))) {
         $q = Student::orderBy('last_name', 'ASC');
         if ($first_name) {
             $q = $q->where('first_name', 'like', "%{$first_name}");
         }
         if ($last_name) {
             $q = $q->where('last_name', 'like', "%{$last_name}");
         }
         if ($zip) {
             $q = $q->where('zip', $zip);
         }
         if ($year) {
             $q = $q->where('year_level', $year);
         }
         if ($section) {
             $q = $q->where('section_id', $section);
         }
         if ($city) {
             $q = $q->where('city', $city);
         }
         if (array_key_exists($age, config('student.brackets'))) {
             $age = explode('-', $age);
             $q = $q->whereBetween('birthday', [Carbon::now()->subYears($age[1])->format('Y-m-d'), Carbon::now()->subYears($age[0])->format('Y-m-d')]);
         }
         return $q;
     }
     return false;
 }
开发者ID:arielmagbanua,项目名称:sis_test,代码行数:37,代码来源:Search.php

示例3: index

 public function index()
 {
     return view('student.index', ['students' => Student::orderBy('name')->get()]);
 }
开发者ID:cat5inthecradle,项目名称:speechteam,代码行数:4,代码来源:StudentController.php

示例4: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $student = Student::find(Crypt::decrypt($id));
     if (count($student) == 0) {
         return response()->json(['success' => false, 'message' => 'Invalid id!']);
     }
     if (!$student->delete()) {
         return response()->json(['success' => false, 'message' => 'Failed to delete record!']);
     }
     $students = Student::orderBy('name')->get();
     return response()->json(['success' => true, 'message' => 'Delete record successful!', 'content' => view('partials.student-table', compact('students'))->render()]);
 }
开发者ID:ramzdam,项目名称:enrollment,代码行数:18,代码来源:StudentController.php

示例5: export

 public function export(Request $request)
 {
     if ($request->get('dob') && $request->get('from') && $request->get('to')) {
         if ($request->get('from') < $request->get('to')) {
             return response()->json(['success' => false, 'message' => 'From date must be lower than TO date']);
         }
         $dt = Carbon::now();
         $dt2 = Carbon::now();
         $from = $dt->subYears($request->get('from'));
         $to = $dt2->subYears($request->get('to'));
         $students = Student::where('dob', '<=', $from)->where('dob', '>=', $to)->orderBy('fname')->get();
     } else {
         $students = Student::orderBy('fname')->get();
     }
     header('Set-Cookie: fileDownload=true; path=/');
     // This is required for the javascript triggering this will know if the transaction was successful.
     $data = $this->generateReportData($students, $request);
     Excel::create('reports-' . date('Ymd'), function ($excel) use($data) {
         $excel->sheet("Student Data", function ($sheet) use($data) {
             $sheet->fromArray($data);
         });
     })->download('xls');
 }
开发者ID:ramzdam,项目名称:enrollment,代码行数:23,代码来源:ReportController.php


注:本文中的app\Student::orderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。