本文整理汇总了PHP中Question::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::all方法的具体用法?PHP Question::all怎么用?PHP Question::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question::all方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
if (Auth::check()) {
$question = Question::all();
return View::make('Exam.exam', compact('questions'));
}
return "No estas logueado como estudiante.";
}
示例2: postQuestionChange
public function postQuestionChange()
{
//message-notification
$messages = array();
//handle navigation
$admin_navigation = new AdminNavigation();
if ($admin_navigation->isNavigate()) {
return $admin_navigation->goToN();
}
//handle chapter-text change
//redirect after changed
if (Input::has('chapter_change')) {
$chapter = Chapter::find(Input::get('chapter_change'));
$chapter->text = Input::get('chapter_text');
$chapter->save();
$messages['chapter_change_text'] = 'chapter-' . $chapter->id . ':saved';
$this->messageController->send($messages, $this::MESSAGE_KEY);
return Redirect::back();
}
//handle delete-question
//redirect after deleted, no need to modify other inputs
if (Input::has('delete_question')) {
$question = Question::find(Input::get('delete_question'));
$store_question_id = $question->id;
$question->delete();
$messages['delete_question'] = 'question-' . $store_question_id . ':deleted';
$this->messageController->send($messages, $this::MESSAGE_KEY);
return Redirect::back();
}
//handle change on a question (both this one, and it's options)
//redirect after all-changes saved
if (Input::has('question_change')) {
$question = Question::find(Input::get('question_change'));
//question-change, change question-text
if (Input::has('question_text')) {
$question->text = Input::get('question_text');
$question->save();
$messages['question_change_text'] = 'question-' . $question->id . ':saved';
}
//question-change, change question-chapter_id
if (Input::has('chapter_id')) {
$question->chapter_id = Input::get('chapter_id');
$question->save();
$new_chapter = $question->getChapter;
$messages['question_change_chapter_id'] = 'question-' . $question->id . ':now belongs to chapter-' . $new_chapter->id;
}
//options-change
if (Input::has('options')) {
$options = Input::get('options');
//save options-change
$i = -1;
foreach ($options as $option_id => $option_text) {
$option = Option::find($option_id);
$option->text = $option_text;
//reset all option-is_right = 0
//is_right set again with input-is_right checked
$option->is_right = 0;
$option->save();
$messages['options_change[' . ++$i . ']'] = 'option-' . $option->id . ':saved';
}
//modify option-is_right
if (Input::has('is_right')) {
$option = Option::find(Input::get('is_right'));
//this option set is_right = 1
$option->is_right = 1;
$option->save();
$messages['options_change_is_right'] = 'option-' . $option->id . '-is_right:saved';
}
}
//send message-notification
$this->messageController->send($messages, $this::MESSAGE_KEY);
return Redirect::back();
}
//new-question
//redirect after create new-one
if (Input::has('new_question')) {
//save new question
$question = new Question();
//delete + auto_increment >>> modify question-id not continuous
//manually change question-id
$last_question = Question::all()->last();
$question->id = $last_question->id + 1;
$question->text = Input::get('question_text');
$question->chapter_id = Input::get('chapter_id');
$question->save();
$question_id = $question->id;
$messages['new_question'] = 'question-' . $question->id . ':saved';
//save new options
$options_text = Input::get('options');
$created_options = array();
for ($i = 0; $i < 4; $i++) {
$option = new Option();
$option->text = $options_text[$i];
$option->question_id = $question_id;
$option->is_right = 0;
$option->save();
//store in array new-option in $created_options, to add is_right on which
$created_options[$i] = $option;
$messages['option[' . $i . ']'] = 'option-' . $option->id . ':saved';
}
//.........这里部分代码省略.........
示例3: array
<?php
include '../../inc/init.inc';
if (isset($tag)) {
$conditions = array('id in (?)', Questions_Tag::find('all', array('conditions' => array('tag_id' => Tag::find_by_name($tag)->id)))->asQuestion_ID());
}
isset($conditions) ? $args['conditions'] = $conditions : ($args['conditions'] = 'title NOT LIKE ""');
$res->total = isset($args) ? Question::count($args) : Question::count();
$res->currentPage = isset($currentPage) ? $currentPage : 1;
$res->limit = $args['limit'] = isset($limit) ? $limit : 7;
$args['offset'] = ($res->currentPage - 1) * $args['limit'];
$args['order'] = isset($order) ? $order : 'created_at desc';
$res->questions = Question::all($args);
$res->tags = Tag::find('all', array('order' => 'Rand()', 'limit' => 20));
if (!isset($infos)) {
$infos = array();
}
$res->search_opts = array(0 => array('label' => 'Quelle question vous posez vous ?', 'field' => 'title', 'type' => 'text', 'class' => 'xxlarge'));
$res->useTemplate("Questions - Reponses", $infos);
示例4: index
public function index()
{
$questions = Question::all();
return View::make('ask.index')->with(['questions' => $questions]);
}
示例5: show
public function show()
{
$questions = Question::all();
return View::make('user.dashboard', ['questions' => $questions]);
}
示例6: function
//$message->from('support@cortana.dev', 'c01tana Ltd');
$message->to('rocardpp@gmail.com', 'rocard')->subject('test mail');
});
return 'done.';
});
Route::get('/', function () {
$data['users'] = User::all();
//$data['questions'] = DB::select( DB::raw("SELECT * FROM `questions` ORDER BY `created_at` DESC LIMIT 1") );
$data['questions'] = Question::orderBy('created_at', 'desc')->paginate(10);
$data['count'] = Question::all()->count();
return View::make('site.home')->with($data);
});
Route::get('questions', function () {
$data['users'] = User::all();
$data['questions'] = Question::orderBy('created_at', 'desc')->paginate(10);
$data['count'] = Question::all()->count();
return View::make('site.questions')->with($data);
});
Route::get('question/{id}/{slug}', function ($id, $slug) {
$data['users'] = User::all();
$data['qvotes'] = Qvote::where('question_id', '=', $id)->get();
$data['question'] = Question::find($id);
$data['answers'] = Answer::where('question_id', '=', $id)->orderBy('votes', 'desc')->get();
$data['comments'] = Comment::where('question_id', '=', $id)->orderBy('created_at', 'desc')->get();
$data['count'] = Answer::where('question_id', '=', $id)->count();
return View::make('site.question')->with($data);
});
Route::get('users', function () {
$data['users'] = User::orderBy('reputation', 'desc')->paginate(20);
return View::make('site.users')->with($data);
});
示例7: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$questions = Question::all();
return View::make('questions.index')->with('questions', $questions);
}
示例8: percentageAll
public static function percentageAll()
{
$number1 = Auth::user()->correctQuestions()->count();
$number2 = Question::all()->count();
if ($number2 == 0) {
$finalNumber = 100;
} else {
$quotient = $number1 / $number2;
$finalNumber = $quotient * 100;
}
return round($finalNumber);
}
示例9: show
/**
* Display the specified resource.
* GET /questions/{id}
*
* @param int $id
* @return Response
*/
public function show($id)
{
return Question::all();
}
示例10: questionsdone
public function questionsdone()
{
$questions = Question::all();
$playerid = Input::get('player');
foreach ($questions as $q) {
$answer = new Answer();
$answername = 'field' . $q->id;
$answer->answer = Input::get($answername);
$answer->player_id = $playerid;
$answer->question_id = $q->id;
$answer->save();
}
return View::make('thanks');
}
示例11: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\JsonResponse
*/
public function index()
{
$questions = Question::all();
return response()->json($questions);
}
示例12: index_admin
public function index_admin()
{
$questions = Question::all();
return View::make('commonquestions.admin_index', compact('questions'));
}