本文整理汇总了PHP中app\models\Language::lists方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::lists方法的具体用法?PHP Language::lists怎么用?PHP Language::lists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Language
的用法示例。
在下文中一共展示了Language::lists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWordsAjax
public function getWordsAjax(Request $request)
{
//print_r($request->all());
if (!$request->ajax()) {
return response()->json(['response' => 'reject', 'msg' => 'request Not Allowed', 'searchWord' => $request->searchWord, 'language' => $request->languageName, 'Ajax' => $request->ajax(), 'Request' => $request->method()]);
}
$languageName = $request->languageName;
$searchWord = $request->searchWord;
$language = new Language();
$languageList = $language->lists('name')->all();
$words = Word::with(['user', 'language']);
if (!in_array($languageName, $languageList)) {
$languageName = '';
} else {
$language_id = $language->where('name', '=', $languageName)->value('id');
$words->where('language_id', '=', $language_id);
}
if ($searchWord != null) {
$words->where('word', 'LIKE', $searchWord . '%');
}
return $words->orderBy('word', 'asc')->limit(15)->get();
}