當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Question::orderBy方法代碼示例

本文整理匯總了PHP中app\Question::orderBy方法的典型用法代碼示例。如果您正苦於以下問題:PHP Question::orderBy方法的具體用法?PHP Question::orderBy怎麽用?PHP Question::orderBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Question的用法示例。


在下文中一共展示了Question::orderBy方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getQuesitions

 public function getQuesitions(Request $request)
 {
     $type = $request->get('type');
     switch ($type) {
         case 0:
             $questions = Question::take(10)->get();
             break;
         case 1:
             $questions = Question::orderBy('total_answer', 'desc')->take(10)->get();
             break;
         case 2:
             $questions = Question::where('issolved', 0)->take(10)->get();
             break;
         default:
             $questions = Question::where('issolved', 1)->take(10)->get();
             break;
     }
     if ($questions) {
         foreach ($questions as &$question) {
             $question['time'] = $question->created_at->diffForHumans();
             $question['username'] = $question->user->name;
         }
         $this->setResult($questions);
         $this->succeed(true);
     } else {
         $this->setResult('questions表獲取記錄失敗!');
         $this->fail(true);
     }
 }
開發者ID:Panfen,項目名稱:mango,代碼行數:29,代碼來源:ForumController.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     if ($request->has('filterBy')) {
         $questions = Question::with('state')->where($request->get('filterBy') . '_id', $request->get('id'))->get();
     } else {
         $questions = Question::orderBy('likes', 'desc')->with('state')->get();
     }
     $states = State::lists('name', 'id');
     return view('admin.questions.index', compact('questions', 'states'));
 }
開發者ID:e-noumene,項目名稱:Back,代碼行數:15,代碼來源:QuestionsController.php

示例3: index

 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     if (Auth::user()) {
         $countryId = Auth::user()->country_id;
     } else {
         $location = GeoIPFacade::getLocation();
         $countryId = Country::where('country_code', '=', $location['isoCode'])->first()->id;
     }
     $questions = Question::whereNotNull('questions.user_id')->whereNotNull('questions.question_category_id')->whereNotNull('questions.country_id')->where('questions.is_displayed', '=', 1)->where('questions.country_id', '=', $countryId)->where('questions_countries.country_id', '=', $countryId)->with('author')->with('category')->with('country')->join('questions_countries', 'questions.id', '=', 'questions_countries.question_id')->orderBy('questions_countries.count', 'DESC')->limit(5)->get();
     $allQuestions = Question::orderBy('updated_at', 'DESC')->paginate(10);
     return view('pages.home', compact('questions', 'allQuestions'));
 }
開發者ID:alex311982,項目名稱:laravel5_online_support,代碼行數:17,代碼來源:HomeController.php

示例4: getQuestion

 /**
  * creating an new question.
  *
  * @return Response
  */
 public function getQuestion()
 {
     $questions = \App\Question::orderBy('created_at', 'DESC')->get()->toArray();
     return response()->json($questions);
 }
開發者ID:nara-l,項目名稱:quizer,代碼行數:10,代碼來源:WelcomeController.php

示例5: showAllQuestions

 public function showAllQuestions()
 {
     $questions = Question::orderBy('id', 'desc')->get();
     return view('questions.all-questions', compact('questions'));
 }
開發者ID:barantr90,項目名稱:resmin-laravel,代碼行數:5,代碼來源:QuestionsController.php

示例6: getAllQuestions

 /**
  * @param string $order_by
  * @param string $sort
  * @return mixed
  */
 public function getAllQuestions($order_by = 'id', $sort = 'asc')
 {
     return Question::orderBy($order_by, $sort)->get();
 }
開發者ID:herzcthu,項目名稱:Laravel-HS,代碼行數:9,代碼來源:EloquentQuestionRepository.php


注:本文中的app\Question::orderBy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。