本文整理匯總了PHP中Answer::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Answer::create方法的具體用法?PHP Answer::create怎麽用?PHP Answer::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Answer
的用法示例。
在下文中一共展示了Answer::create方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
public function run()
{
$answers = ["Yes.", "Yes - definitely.", "Reply hazy, try again...", "Without a doubt.", "My sources say no.", "As I see it, yes.", "You may rely on it.", "Concentrate and ask again...", "Outlook not so good.", "It is decidedly so.", "Better not tell you now...", "Very doubtful...", "It is certain.", "Cannot predict now...", "Most likely...", "Ask again later...", "My reply is no.", "Outlook good.", "Don't count on it."];
foreach ($answers as $answer) {
Answer::create(array('body' => $answer));
}
}
示例2: post_create_document
public function post_create_document()
{
$document_id = Input::get('document_id');
$user_id = Auth::user()->id;
// we want to get all the input data
//
// take apart the name and value pairs
//
$inputs = Input::all();
//dd($inputs);
foreach (Input::all() as $name => $value) {
if ($name != '0' || $name != 'csrf_token') {
// for some reason, laravel id=gnores form fields with nums as
// the name value so this will fix it
// along with the <input name="id45"..
$name = str_replace('id', '', $name);
Answer::create(array('document_id' => $document_id, 'user_id' => $user_id, 'field_id' => $name, 'answer' => $value));
}
// dd(array(
// 'document_id' => $document_id,
// 'user_id' => $user_id,
// 'field_id' => $key,
// 'answer' => $value
// ));
}
return Redirect::to_route('tenant_view_document', $document_id);
}
示例3: store
/**
* Store a newly created resource in storage.
* POST /answers
*
* @return Response
*/
public function store()
{
$answers = Answer::create(Input::all());
if ($answers) {
return ['status' => true, 'data' => $answers];
} else {
return ['status' => false];
}
}
示例4: run
public function run()
{
DB::table('Players')->delete();
DB::table('Questions')->delete();
DB::table('Questionnaires')->delete();
DB::table('Answers')->delete();
$kim = Questionnaire::create(array('name' => 'kim'));
$frage1 = Question::create(array('question' => 'Das Spiel hat mir Spass gemacht', 'questionnaire_id' => $kim->id));
$playerJustus = Player::create(array('gender' => 'm', 'age' => '21', 'computer' => '4', 'game' => '3', 'questionnaire_id' => $kim->id));
$Testfrage = Answer::create(array('answer' => 'Test', 'player_id' => $playerJustus->id, 'question_id' => $frage1->id));
}
示例5: updatePoll
public function updatePoll()
{
$poll_title = Input::get('poll_title');
$poll_id = Input::get('poll_id');
$new_poll_questions = Input::get('new_poll_questions');
$new_poll_questions_count = count($new_poll_questions);
$poll = Poll::find($poll_id);
if (isset($poll_title)) {
$poll->title = $poll_title;
$poll->save();
}
for ($i = 0; $i < $new_poll_questions_count; $i++) {
if (isset($new_poll_questions[$i])) {
$question = Question::create(array('created_by' => Auth::user()->id, 'content' => $new_poll_questions[$i], 'poll_id' => $poll_id));
$question->save();
}
}
foreach ($poll->questions as $question) {
$save_question = Question::find($question->id);
$save_question->content = Input::get('question-' . $question->id);
$save_question->save();
foreach ($question->answers as $answer) {
$save_answer = Answer::find($answer->id);
$save_answer->content = Input::get('answer-' . $answer->id);
$save_answer->save();
}
$new_poll_answers = Input::get('new_poll_answers-' . $question->id);
if (isset($new_poll_answers)) {
$new_poll_answers_count = count($new_poll_answers);
for ($i = 0; $i < $new_poll_answers_count; $i++) {
if (isset($new_poll_answers[$i])) {
$answer = Answer::create(array('created_by' => Auth::user()->id, 'content' => $new_poll_answers[$i], 'question_id' => $question->id));
$answer->save();
}
}
}
}
return Redirect::action('PollController@editPoll', array('title' => $poll_title));
// return View::make('edit-poll')
// ->with('poll',$poll);
}
示例6: Answer
<?php
require '../class/class_answer.php';
if (isset($_POST) && !empty($_POST)) {
$answer = new Answer();
$answer->setContent($_POST['content']);
$answer->setIdQuestion($_POST["idQuestion"]);
$answer->setIdAuthor($_POST["idAuthor"]);
$answer->create();
var_dump($answer);
exit;
}
示例7: getAnswer
public function getAnswer()
{
$_GET['keyword'];
$answer = Answer::create(['answer_title' => $_GET['keyword'], 'question_id' => $_GET['keyword1']]);
return Redirect::to('backends/quizz/edit/' . $_GET['keyword1']);
}
示例8: action_edit
public static function action_edit($id = null)
{
if (!IS_ADMIN) {
Redirect::to(Url::get('admin@login', null, 'redirect-to=' . urlencode(Url::current())));
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($id === 'delete-answer') {
if (($answer_id = Param::post('answer_id')) && is_numeric($answer_id)) {
$answer = Answer::get((int) $answer_id);
Answer::find((int) $answer_id)->delete();
$votes = Vote::where('answer_id', '=', $answer_id)->count();
if ($votes) {
Poll::find($answer->poll_id)->set(array('nofilter:total_votes' => "`total_votes` - {$votes}"));
}
return Response::json(array('status' => 200, 'deleted' => true));
} else {
return Response::json(array('status' => 0, 'deleted' => false));
}
} elseif ($id) {
return Response::error(404);
} else {
$id = Param::post('id');
if ($answer_id = Param::post('remove_answer')) {
Answer::find((int) $answer_id)->and_where('poll_id', '=', $id)->delete();
$votes = Vote::where('answer_id', '=', $answer_id)->count();
if ($votes) {
Poll::find($id)->set(array('nofilter:total_votes' => "`total_votes` - {$votes}"));
}
Redirect::to(Url::get('admin@edit', $id, 'answer_deleted=true'));
}
if (Param::post('remove_poll')) {
Poll::find($id)->delete();
Redirect::to(Url::get('admin', null, 'poll_deleted=true'));
}
if (is_numeric($id) && ($poll = Poll::get((int) $id))) {
foreach ($_POST as $key => $value) {
if (isset($poll->{$key}) && (!empty($_POST[$key]) || $_POST[$key] === "0")) {
$poll->{$key} = is_numeric($_POST[$key]) ? intval($_POST[$key], 10) : $_POST[$key];
} elseif (false !== strpos($key, 'answer-')) {
$answer_id = explode('-', $key);
$answer_id = $answer_id[1];
if (is_numeric($answer_id)) {
Answer::find((int) $answer_id)->set(array('text' => $value));
}
} elseif ($key === 'new_answers') {
foreach ($value as $new_answer) {
if (!empty($new_answer)) {
Answer::create(array('poll_id' => (int) $poll->id, 'text' => $new_answer));
}
}
}
}
Poll::save($poll);
Redirect::to(Url::get('admin', null, 'success=' . $_POST['id'] . '&updated=true'));
} else {
return Response::error(500);
}
}
}
if (!$id || !is_numeric($id) || !($poll = Poll::get((int) $id))) {
return Response::error(404);
} else {
$answers = Answer::where('poll_id', '=', $poll->id)->get();
return View::make('admin.edit')->add_var('answers', $answers)->add_var('poll', $poll);
}
}