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


PHP Answer::create方法代码示例

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

示例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);
 }
开发者ID:andyfoster,项目名称:tenantplus,代码行数:27,代码来源:tenants.php

示例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];
     }
 }
开发者ID:anildukkipatty,项目名称:fu,代码行数:15,代码来源:AnswersController.php

示例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));
 }
开发者ID:sanderdrummer,项目名称:Homepages,代码行数:11,代码来源:DatabaseSeeder.php

示例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);
 }
开发者ID:netintelpro,项目名称:laravel-app,代码行数:41,代码来源:PollController.php

示例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;
}
开发者ID:Terror404,项目名称:NDLI2015,代码行数:12,代码来源:ajout-answer.php

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

示例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);
     }
 }
开发者ID:jruizdes,项目名称:encuestamanki,代码行数:66,代码来源:admin.php


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