当前位置: 首页>>代码示例>>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;未经允许,请勿转载。