本文整理汇总了PHP中app\Question::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::all方法的具体用法?PHP Question::all怎么用?PHP Question::all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Question
的用法示例。
在下文中一共展示了Question::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$questions = Question::all();
$tpl['user'] = \Auth::user();
$tpl['questions'] = $questions;
return view('home', $tpl);
}
示例2: createQuestion
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function createQuestion()
{
$questions = \App\Question::all();
$user = \Auth::user();
$fiche_id = Session::get('fiche_id');
return view('back.newQuestion', compact('questions', 'fiche_id', 'user'));
}
示例3: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$questions = Question::all();
$data = array();
$data['questions'] = $questions;
$data['languages'] = Language::all();
return view('questions.index', $data);
}
示例4: index
/**
* The game page itself
*
* @return Response
*/
public function index()
{
$ws = Websitespel::where("ended", false)->orderBy('start_date')->first();
if ($ws == null) {
//no games in progress and none planned
//return done
return view('game.ended')->with('countDown', false);
} else {
if ($ws->start_date > \Carbon\Carbon::now()) {
// do the countdown
// return countdown
return view('game.countdown')->with('countDown', $ws);
}
}
// else carry on
$team = Auth::user()->team()->first();
$questionNr = count(Progress::where('team_id', $team->id)->get());
$question = null;
$tip = false;
$times = [];
if ($questionNr != count(Question::all())) {
$question = Question::where('sequence', $questionNr + 1)->first();
$result = QuestionTime::where('team_id', $team->id)->where('question_id', $question->id)->get();
if (count($result) == 0) {
$questionTime = new QuestionTime();
$questionTime->team_id = $team->id;
$questionTime->question_id = $question->id;
$questionTime->tip = false;
$questionTime->start_time = \Carbon\Carbon::now()->timestamp;
$questionTime->save();
$tip = false;
} else {
$tip = $result->first()->tip;
}
} else {
$teams = Team::all();
$teamsCount = count($teams);
$question_id = Question::where('sequence', Question::max('sequence'))->first()->id;
for ($i = 0; $i < $teamsCount; $i++) {
$qt = QuestionTime::where('team_id', $teams[$i]->id)->where('question_id', $question_id)->first();
if ($qt == null) {
continue;
}
$end_time = $qt->end_time;
if ($end_time == null) {
continue;
}
$end_time_string = \Carbon\Carbon::createFromTimestamp($end_time);
array_push($times, array('name' => $teams[$i]->teamname, 'time' => $end_time_string, 'countDown' => 0));
}
usort($times, function ($a, $b) {
return $a['time']->timestamp - $b['time']->timestamp;
});
}
return view('game.index')->with(array('question' => $question, 'tip' => $tip, 'end_times' => $times, 'countDown', null));
}
示例5: questions
public static function questions()
{
if (Gate::allows('view_question')) {
return Question::all();
} elseif (Auth::check() && Gate::allows('view_own_question')) {
return Question::where('user_id', Auth::id())->get();
} else {
return null;
}
}
示例6: show
public function show()
{
/*return Datatables::of(Question::all())
->addColumn('qtitle', function($model){
return $model->qtitle;
})
->addColumn('answer', function($model){
return $model->answer;
})
->searchColumns('qtitle', 'answer')
->orderColumns('qtitle', 'answer')
->make(true);*/
$questions = Question::all();
return view('questions.show', compact('questions'));
}
示例7: index
/**
* Show the questions list to the user.
*
* @return Response
*/
public function index()
{
try {
$data['questions'] = Question::all();
if (isset($data['questions']) && count($data['questions']) > 0) {
//get Answers of first question with added user name
$data['firstAnswers'] = Answer::leftJoin('users', function ($join) {
$join->on('answers.user_id', '=', 'users.id');
})->where("question_id", "=", $data['questions'][0]->id)->get(['answers.id', 'answers.answer', 'answers.question_id', 'users.id', 'users.name']);
}
return view('question.view', $data);
} catch (Exception $e) {
return redirect()->back()->withInput()->withErrors($e->getMessage());
}
}
示例8: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
// this should limit the number of queries but need more digging
// eager loading
//$questions = Question::with('replies')->get();
$questions = Question::all();
$user = Auth::user();
if (!Auth::check()) {
return redirect('home')->with('message', "Veuillez d'abord vous connecter");
}
foreach ($questions as $question) {
if ($question->getAnswer()) {
$question->replied = true;
} else {
$question->replied = false;
}
}
return view('questions.index')->with('questions', $questions);
}
示例9: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$questions = Question::all()->sortByDesc('created_at');
return view('questions.index', compact('questions'));
}
示例10: edit_question
public function edit_question()
{
$data = Input::all();
$event = Event::where('id', Session::get('event_id'))->first();
$question = Question::where('id', '=', Session::get('qid'))->first();
$question->event_id = Session::get('event_id');
$question->question = $data['question'];
$image = array();
if (isset($data['file'])) {
if (Input::file('file')->isValid()) {
$destinationPathvfile = 'uploads';
$extensionvfile = Input::file('file')->getClientOriginalExtension();
$fileNamevfile = $event->id . '.' . $extensionvfile;
// renaming image
Input::file('file')->move($destinationPathvfile, $fileNamevfile);
$question->image = $fileNamevfile;
}
}
if (isset($data['html'])) {
$question->html = $data['html'];
}
if (intval($event->type) > 2) {
$question->options = serialize($data['options']);
$answers = $data['answers'];
$question->save();
Session::put('qid', Question::all()->last()->id);
$answer = Answer::where('ques_id', '=', Session::get('qid'))->delete();
foreach ($answers as $ans) {
$answer = new Answer();
$answer->ques_id = Session::get('qid');
$answer->answer = $ans;
$answer->score = 1;
$answer->incorrect = 0;
$answer->save();
}
} else {
$question->level = $data['level'];
$question->save();
Session::put('qid', Question::all()->last()->id);
$answer = Answer::where('ques_id', '=', Session::get('qid'))->first();
$answer->ques_id = Session::get('qid');
$answer->answer = $data['answer'];
$answer->score = 1;
$answer->incorrect = 0;
$answer->save();
}
Session::put('event_id', $event->id);
return Redirect::route('viewquestions', ['event_id' => $event->id])->with('message', 'Question Successfully Edited');
}
示例11: index
public function index()
{
$questions = \App\Question::all();
return view('admin.questions.index', compact('questions'));
}
示例12: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$questions = Question::all();
return $questions->toJson();
}
示例13: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$questions = Question::all();
return view('questions.index');
}
示例14: create
public function create()
{
$questions = Question::all()->groupBy('topic_id');
$topics = Topic::all()->pluck('text', 'id')->all();
return view('questionaire.create', compact('questions', 'topics'));
}
示例15: store
/**
* stores a new question in the database.
*
* @param Request $request the request
* @return redirect back to the questions overview
*/
public function store(Request $request)
{
$question = $request->all();
if (!array_key_exists('tip_alters_question', $question)) {
$question['tip_alters_question'] = false;
}
$question['sequence'] = count(Question::all()) + 1;
$question = Question::create($question);
return redirect("admin/questions/" . $question->id);
}