当前位置: 首页>>代码示例>>PHP>>正文


PHP Question::all方法代码示例

本文整理汇总了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);
 }
开发者ID:bhasunjaya,项目名称:askpeople,代码行数:7,代码来源:HomeController.php

示例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'));
 }
开发者ID:Vever,项目名称:projetLycee2015,代码行数:12,代码来源:QuestionController.php

示例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);
 }
开发者ID:alexpcoleman,项目名称:fitl,代码行数:13,代码来源:QuestionController.php

示例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));
 }
开发者ID:jvanraemdonck,项目名称:Websitespel,代码行数:61,代码来源:GameController.php

示例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;
     }
 }
开发者ID:jamesvillarrubia,项目名称:mtc-api,代码行数:10,代码来源:GateCheck.php

示例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'));
 }
开发者ID:a8212270,项目名称:QuizPlatFormWeb,代码行数:15,代码来源:QuestionController.php

示例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());
     }
 }
开发者ID:fakrunt,项目名称:itmarkerz,代码行数:20,代码来源:QuestionController.php

示例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);
 }
开发者ID:philippejadin,项目名称:mooc,代码行数:24,代码来源:QuestionsController.php

示例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'));
 }
开发者ID:sajadtorkamani,项目名称:qanda,代码行数:10,代码来源:QuestionsController.php

示例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');
 }
开发者ID:ncs-jss,项目名称:elastic-heart,代码行数:49,代码来源:QuestionsController.php

示例11: index

 public function index()
 {
     $questions = \App\Question::all();
     return view('admin.questions.index', compact('questions'));
 }
开发者ID:EmilAleksandrov,项目名称:Cinegrand-laravel-5.1-ajax,代码行数:5,代码来源:QuestionController.php

示例12: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $questions = Question::all();
     return $questions->toJson();
 }
开发者ID:Cap-y,项目名称:ImperierumChallenge,代码行数:10,代码来源:QuestionController.php

示例13: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $questions = Question::all();
     return view('questions.index');
 }
开发者ID:jhcict,项目名称:mcq,代码行数:10,代码来源:QuestionController.php

示例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'));
 }
开发者ID:patrick-durrer,项目名称:feedback,代码行数:6,代码来源:QuestionaireController.php

示例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);
 }
开发者ID:jvanraemdonck,项目名称:Websitespel,代码行数:16,代码来源:QuestionController.php


注:本文中的app\Question::all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。