本文整理汇总了PHP中app\Question::eligible方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::eligible方法的具体用法?PHP Question::eligible怎么用?PHP Question::eligible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Question
的用法示例。
在下文中一共展示了Question::eligible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Displays appropriate question to the user
*
* @param null $category
* @return \Illuminate\Http\RedirectResponse|
* \Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function show($category = null)
{
$id = \Auth::id();
$answered_questions = \DB::table('question_user')->where('user_id', '=', $id)->get(array('question_id'));
$answered_questions = json_decode(json_encode($answered_questions), true);
$categories = ['history', 'sports', 'science', 'literature', 'politics'];
if ($category == null) {
$question = Question::eligible($id, $answered_questions)->get()->toArray();
} else {
if (in_array($category, $categories)) {
$question = Question::where('category', '=', $category)->eligible($id, $answered_questions)->get()->toArray();
} else {
\Session::flash('heading', 'Oops!!');
\Session::flash('message', 'You are trying to access a wrong category');
return redirect('/');
}
}
return view('play.index', compact('question', 'category'));
}