本文整理汇总了PHP中app\Question::orderByRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::orderByRaw方法的具体用法?PHP Question::orderByRaw怎么用?PHP Question::orderByRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Question
的用法示例。
在下文中一共展示了Question::orderByRaw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showTrois
public function showTrois($tag)
{
$ids = session('ids');
$idss = session('ids');
$idss .= '|' . $tag . '|' . $ids;
session(['ids' => $idss]);
$token = new \Tmdb\ApiToken('API_KEY');
$client = new \Tmdb\Client($token, ['secure' => false]);
$questions = Question::orderByRaw('RAND()')->take(1)->get();
$response = $client->getDiscoverApi()->discoverMovies(['page' => 1, 'language' => 'fr', 'with_keywords' => $idss]);
return view('pages/question4', ['response' => $response, 'questions' => $questions]);
}
示例2: getQAList
public function getQAList(Request $request)
{
$data = $request->all();
$question = Question::orderByRaw("RAND()")->where('stages_id', $data['stagesId'])->get()->take(5);
//->take(5)
for ($i = 0; $i < count($question); $i++) {
$checkFavorite = Favorite::where('user_id', $data['user_id'])->where('question_id', $question[$i]['id'])->first();
if ($checkFavorite == null) {
$question[$i]['favorite'] = 0;
} else {
$question[$i]['favorite'] = 1;
}
}
return response()->json(['RetCode' => '1', 'Content' => ['image' => 'ZH4itjY.jpg', 'questions' => $question]]);
}