當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。