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


PHP Answer::where方法代码示例

本文整理汇总了PHP中Answer::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Answer::where方法的具体用法?PHP Answer::where怎么用?PHP Answer::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Answer的用法示例。


在下文中一共展示了Answer::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * Update the specified resource in storage.
  * PUT /answers/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $answers = Answer::where('id', $id)->update(Input::all());
     if ($answers) {
         return ['status' => true, 'data' => $answers];
     } else {
         return ['status' => false];
     }
 }
开发者ID:anildukkipatty,项目名称:fu,代码行数:16,代码来源:AnswersController.php

示例2: getActivity

 public function getActivity()
 {
     $data['user'] = User::find(Auth::user()->id);
     $data['userQustions'] = Question::where('user_id', '=', User::find(Auth::user()->id)->id)->orderBy('created_at', 'desc')->get();
     $data['questionsCount'] = $data['userQustions']->count();
     $data['userAnswers'] = Answer::where('user_id', '=', User::find(Auth::user()->id)->id)->orderBy('created_at', 'desc')->get();
     $data['answersCount'] = $data['userAnswers']->count();
     return View::make('profile.activity')->with($data);
 }
开发者ID:Roc4rdho,项目名称:ubexchange,代码行数:9,代码来源:ProfileController.php

示例3: download

 public function download($testId, $countIt = FALSE)
 {
     $testId = (int) $testId;
     $test = new Test();
     $cvs = 'id,姓名,学号';
     $test->get_by_id($testId);
     if ($test->id) {
         $topics = $test->topic->get();
         $users = $test->user->where(array('uType' => 'student'))->get();
         $topicsData = new Stdclass();
         $usersData = new StdClass();
         $answersData = new Stdclass();
         foreach ($topics->all as $topic) {
             $topicsData->{$topic->id} = $topic->to_array();
             for ($i = 1; $i <= $topic->tocMax; $i++) {
                 $cvs .= ',' . $topic->tocTitle . '_' . $i;
             }
         }
         foreach ($users->all as $user) {
             $usersData->{$user->id} = $user->to_array();
             $answers = new Answer();
             $answers->where(array('user_id' => $user->id))->get();
             $cvs .= "\n" . $user->id . ',' . $user->uName . ',' . (string) $user->uStudId;
             foreach ($answers->all as $answer) {
                 $answersData->{$answer->topic_id} = explode(',', $answer->aChoose);
             }
             foreach ($topicsData as $topic_id => $topic) {
                 if (isset($answersData->{$topic_id})) {
                     $aChoose = $answersData->{$topic_id};
                 }
                 for ($i = 0; $i < $topic['tocMax']; $i++) {
                     if (isset($aChoose[$i])) {
                         $cvs .= ',' . $aChoose[$i];
                     } else {
                         $cvs .= ',' . '0';
                     }
                 }
                 $aChoose = NULL;
             }
             $answersData = NULL;
             //原来没有重置,导致问题
             $answers = NULL;
         }
         $this->load->helper('download');
         $cvs = iconv('UTF-8', 'GB2312', $cvs);
         if ($countIt) {
             $cvsCount = $this->downloadCount($cvs);
             force_download('result_' . $testId . '.csv', $cvsCount);
         } else {
             force_download('origin_' . $testId . '.csv', $cvs);
         }
     }
 }
开发者ID:htom78,项目名称:peersay,代码行数:53,代码来源:tests.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\ExamRequest $request)
 {
     $result;
     $selected;
     $count = 0;
     foreach ($request->all() as $index => $answer) {
         $results = Answer::where('question_id', $index)->lists('answer');
         foreach ($results as $result) {
             if ($result == $answer) {
                 $count++;
             }
         }
     }
     return $count;
 }
开发者ID:newgenesisdesigns,项目名称:laravel5,代码行数:20,代码来源:ExamsController.php

示例5: getEdit

 public function getEdit($id = 0)
 {
     $data['id'] = $id;
     $data['question'] = Question::find($id);
     $data['pageTitle'] = "Quizzler | Edit";
     $data['urlAddBack'] = "backends/dashboard";
     $data['btnAddBack'] = '<i class="icon-reply"></i><span>Back<span>';
     $data['labelPage'] = "Edit Question";
     $data['activeD'] = 'active';
     $data['formOrigin'] = "edit";
     $data['answers'] = Answer::where('question_id', $id)->get();
     $correctArr = ['' => '-- Select correct answer --'];
     $data['correctAnswer'] = array();
     foreach ($data['answers'] as $val) {
         $correctArr[$val->id] = $val->answer_title;
         $data['correctAnswer'] = $correctArr;
     }
     $data['correctAn'] = $data['question']->correct_answer;
     return View::make('backends.quizz.quizzAddEdit', $data);
 }
开发者ID:imranshuvo,项目名称:QuizzApps,代码行数:20,代码来源:AdminQuizzController.php

示例6: _save

 protected function _save($data)
 {
     $obj = new Answer();
     $condition = array('user_id' => $this->_user->id, 'topic_id' => $data->topic_id);
     $obj->where($condition)->get();
     if (isset($data->selected) and $data->selected) {
         foreach ($data->selected as $tid => $choose) {
             $newData = new StdClass();
             $newData->topic_id = $tid;
             $newData->aChoose = $choose;
             $this->_save($newData);
         }
     }
     $obj->aChoose = implode(',', $data->aChoose);
     $obj->topic_id = $data->topic_id;
     $obj->user_id = $this->_user->id;
     if ($obj->save()) {
         return $obj->to_array();
     } else {
         return array('error' => $obj->error->string);
     }
 }
开发者ID:htom78,项目名称:peersay,代码行数:22,代码来源:answers.php

示例7: action_vote

 public static function action_vote($id = null)
 {
     if (!$id) {
         if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
             return Response::error(404);
         } else {
             $id = (int) Param::post('id');
             $answers = Param::post('answers');
             $poll = Poll::get($id);
             $poll->various_answers = '0' != $poll->various_answers;
             $cookiename = 'p_' . $poll->id . '_v';
             // Si no hay respuestas o hay más de una respuesta
             if (count($answers) === 0 || !$poll->various_answers && count($answers) > 1) {
                 Redirect::to(Url::get('vote', $id, 'vote_error=true'));
             }
             if (Vote::where('voter_ip', '=', CURRENT_USER_IP)->and_where('poll_id', '=', $id)->first() || Cookie::get($cookiename)) {
                 Cookie::set($cookiename, !$poll->various_answers ? (string) $answers[0] : 'true', 360);
                 Redirect::to(Url::get('view', $poll->slug, 'poll_already_voted=true'));
             }
             Cookie::set($cookiename, !$poll->various_answers ? (string) $answers[0] : 'true', 360);
             Vote::create(array('voter_ip' => CURRENT_USER_IP, 'poll_id' => $id, 'answer_id' => !$poll->various_answers ? $answers[0] : 0));
             foreach ($answers as $answer_id) {
                 Answer::find($answer_id)->set(array('nofilter:votes' => '`votes` + 1'));
             }
             Poll::find($id)->set(array('nofilter:total_votes' => '`total_votes` + 1'));
             Redirect::to(Url::get('view', $poll->slug, 'voted=true'));
         }
     } elseif (!is_numeric($id)) {
         return Response::error(404);
     }
     $id = intval($id, 10);
     if (!($poll = Poll::get($id))) {
         return Response::error(404);
     }
     $answers = Answer::where('poll_id', '=', $poll->id)->get();
     return View::make('vote')->add_var('poll', $poll)->add_var('answers', $answers);
 }
开发者ID:jruizdes,项目名称:encuestamanki,代码行数:37,代码来源:home.php

示例8: storeVersionAction

 /**
  * Store new version of the test
  */
 public function storeVersionAction()
 {
     $data = Input::all();
     $id = $data['id'];
     unset($data['id']);
     $validation = Validator::make($data, Test::$rules);
     if (!$validation->passes()) {
         return Redirect::route('version.create', ['id' => $id])->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
     }
     if (!$data['category_id']) {
         return Redirect::route('version.create', ['id' => $id])->withInput()->with('message', 'Укажите категорию теста.');
     }
     /**
      * Check name duplicates
      */
     if (count(Test::where('name', $data['name'])->where('version', (int) $data['version'])->get())) {
         /**
          * This test exists, generate new version
          */
         $data['version'] = $this->getNextVersion($data['name']);
     }
     $data['user_id'] = Auth::user()->getId();
     $data['active'] = false;
     $data['duration'] = $data['duration'] * 60;
     $test = Test::create($data);
     /**
      * Clone all Questions and Answers
      */
     $questions = Question::where('test_id', $id)->get();
     foreach ($questions as $q) {
         $new = $q->replicate();
         $new->test_id = $test->id;
         $new->save();
         $answers = Answer::where('question_id', $q->id)->get();
         foreach ($answers as $a) {
             $newa = $a->replicate();
             $newa->question_id = $new->id;
             $newa->save();
         }
     }
     return Redirect::route('tests.show', $test->id);
 }
开发者ID:himor,项目名称:testing,代码行数:45,代码来源:TestsController.php

示例9: sizeof

                  
					<div class="portlet-body">
						{{ Form::open(array('url' => 'backends/quizz', 'role' => 'form')) }}
							<div class="form-body">
								<?php 
$i = 1;
?>
								{{ Form::hidden('questionsLenght', sizeof($questions), array('id' => 'questions')) }}
								@foreach($questions as $question)
									{{ Form::hidden('currentQuestion'.$i, $question->id) }} 
									<div class="form-group">
										<div class="col-md-11">
											{{ $i++ }} - {{ Form::label('topic', $question->topic) }}

											<?php 
$answers = Answer::where('question_id', $question->id)->orderBy('id', 'asc')->get();
?>
											@foreach($answers as $answer)	
												<div class="radio-list">
													<label>
														@if($formOrigin=='dashboard')
														<?php 
$j = $i - 1;
?>
														{{ Form::radio('optionsRadios'.$j.$question->id, $answer->id, (Input::old('optionsRadios'.$j) == $answer->id), array('id'=>'optionsRadio', 'class'=>'radio optionsRadios'.$j)) }}
														@endif
														{{ Form::label($answer->id , $answer->answer_title) }}
													</label>
												</div>
											@endforeach	
										</div>
开发者ID:imranshuvo,项目名称:QuizzApps,代码行数:30,代码来源:dashboard.blade.php

示例10: getSearch

 public function getSearch()
 {
     $keyword = Input::get('keyword');
     return View::make('audiopedia.result')->with('answers', Answer::where('title', 'LIKE', '%' . $keyword . '%')->get())->with('keyword', $keyword);
 }
开发者ID:ayooby,项目名称:whatisit,代码行数:5,代码来源:SearchController.php

示例11: getDeletequestion

 public function getDeletequestion()
 {
     Question::find($_GET['keyword'])->delete();
     Answer::where('question_id', $_GET['keyword'])->delete();
     return Redirect::to('backends/dashboard');
 }
开发者ID:imranshuvo,项目名称:QuizzApps,代码行数:6,代码来源:AdminDashboardController.php

示例12: foreach

 function questionaire_save()
 {
     /*echo '<pre>';
     		print_r($_POST);
     		echo '</pre>';
     		exit();*/
     foreach ($_POST['question_id'] as $key => $value) {
         if ($_POST['type'][$key] == "text" || $_POST['type'][$key] == "textarea" || $_POST['type'][$key] == "radio" || $_POST['type'][$key] == "scale") {
             if (@$_POST['answer'][$value]) {
                 $answer = new Answer();
                 if (is_login()) {
                     $answer->where('user_id', $this->session->userdata('id'));
                     $answer->where('questionaire_id', $value)->get();
                     $answer->user_id = $this->session->userdata('id');
                 }
                 $answer->questionaire_id = $value;
                 $answer->answer = $_POST['answer'][$value];
                 $answer->save();
             }
         } elseif ($_POST['type'][$key] == "radio") {
             if (@$_POST['answer'][$value]) {
                 $answer = new Answer();
                 if (is_login()) {
                     $answer->where('user_id', $this->session->userdata('id'));
                     $answer->where('questionaire_id', $value)->get();
                     $answer->user_id = $this->session->userdata('id');
                 }
                 $answer->questionaire_id = $value;
                 $answer->choice_id = $_POST['answer'][$value];
                 $answer->save();
             }
         } elseif ($_POST['type'][$key] == "checkbox") {
             if (@$_POST['answer'][$value]) {
                 $answer = new Answer();
                 $answer->where('user_id', $this->session->userdata('id'));
                 $answer->where('questionaire_id', $value)->get()->delete_all();
                 foreach ($_POST['answer'][$value] as $key => $ans) {
                     if (is_login()) {
                         $answer = new Answer();
                         $answer->user_id = $this->session->userdata('id');
                     }
                     $answer->questionaire_id = $value;
                     $answer->choice_id = $ans;
                     $answer->save();
                 }
             }
         } elseif ($_POST['type'][$key] == "grid") {
             if (@$_POST['answer'][$value]) {
                 foreach ($_POST['answer'][$value] as $key => $ans) {
                     $answer = new Answer();
                     if (is_login()) {
                         $answer->where('user_id', $this->session->userdata('id'));
                         $answer->where('choice_id', $key);
                         $answer->where('questionaire_id', $value)->get();
                         $answer->user_id = $this->session->userdata('id');
                     }
                     $answer->questionaire_id = $value;
                     $answer->choice_id = $key;
                     $answer->answer = $ans;
                     $answer->save();
                 }
             }
         }
     }
 }
开发者ID:unisexx,项目名称:thaigcd2015,代码行数:65,代码来源:docs.php

示例13: 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

示例14: getAttributeForNext

 private function getAttributeForNext($listAnsPoint)
 {
     $getInteractionCount = function ($idAttribute) {
         $interactionTable = Interaction::getTableName();
         return Answer::where('id_attribute', $idAttribute)->join($interactionTable, $interactionTable . '.id_answer_from', '=', Answer::getTableName() . '.id')->count(DB::raw('DISTINCT ' . $interactionTable . '.id_answer_to'));
     };
     $tempScoreAttribute = [];
     foreach ($listAnsPoint as $ansPoint) {
         if (empty($tempScoreAttribute[$ansPoint['attribute']])) {
             $tempScoreAttribute[$ansPoint['attribute']] = ['hasScore' => 0, 'numAns' => 0, 'levelMin' => self::VC, 'numInter' => $getInteractionCount($ansPoint['attribute']), 'id' => $ansPoint['attribute']];
         }
         $tempScoreAttribute[$ansPoint['attribute']]['numAns']++;
         if ($ansPoint['point'] !== null) {
             $tempScoreAttribute[$ansPoint['attribute']]['hasScore']++;
             $tempScoreAttribute[$ansPoint['attribute']]['levelMin'] = min($tempScoreAttribute[$ansPoint['attribute']]['levelMin'], $ansPoint['level']);
         }
     }
     usort($tempScoreAttribute, function ($a, $b) use($getInteractionCount) {
         $conA = $a['numAns'] - $a['hasScore'];
         $conB = $b['numAns'] - $b['hasScore'];
         return $b['levelMin'] > $a['levelMin'] || $b['levelMin'] > $a['levelMin'] && $conB > $conA || $b['levelMin'] > $a['levelMin'] && $conB == $conA && $b['numInter'] > $a['numInter'] || $b['levelMin'] > $a['levelMin'] && $conB == $conA && $b['numInter'] == $a['numInter'] && $b['levelMin'] > $a['levelMin'];
     });
     $item = $tempScoreAttribute[0];
     if ($item['hasScore'] == $item['numAns'] && $item['levelMin'] == 1) {
         return null;
     }
     return $item['id'];
 }
开发者ID:phucps89,项目名称:Tour,代码行数:28,代码来源:AdviceController.php

示例15: postDeleteuser

 public function postDeleteuser()
 {
     $userid = Input::get('id');
     $user = User::find($userid);
     $event = Input::get('event');
     $useranswers = Answer::where('user_id', '=', $userid)->get();
     $userranks = Supplierrank::where('userid', '=', $userid)->get();
     if ($event == "Rescom Summit Bangalore 2016") {
         $qid1 = "3124";
     }
     if ($event == "Design Mission Turkey 2016") {
         $qid1 = "5707";
     }
     if ($event == "Design Mission South West 2016") {
         $qid1 = "5197";
     }
     if ($event == "Design Mission South Africa 2016") {
         $qid1 = "4687";
     }
     if ($event == "Design Mission Saudi Arabia 2016") {
         $qid1 = "3667";
     }
     if ($event == "Design Mission North East 2016") {
         $qid1 = "4177";
     }
     if ($event == "Design Mission Asia 2016") {
         $qid1 = "6217";
     }
     if ($event == "Healthscape Series 2016") {
         $qid1 = "6727";
     }
     if ($event == "Hotelier Summit Africa 2016") {
         $qid1 = "7205";
     }
     if ($event == "Design Mission Middle East 2016") {
         $qid1 = "7654";
     }
     if ($event == "Hotelier Summit India Ose 2016") {
         $qid1 = "8103";
     }
     if ($event == "Hotelier Summit India Ffe 2016") {
         $qid1 = "8552";
     }
     foreach ($userranks as $rank) {
         $rank->delete();
     }
     foreach ($useranswers as $answer) {
         $answer->delete();
     }
     $user->delete();
     $users = User::where('event', '=', $event)->orderby('name')->with(array('answer' => function ($q) use($qid1) {
         $q->where('question_id', '=', $qid1)->orWhere('question_id', '=', $qid1 + 1);
     }))->get();
     return Redirect::to('admin/listuser')->with(array('liusers' => $users, 'liev' => $event, 'createusermessage' => 'User records Deleted'));
 }
开发者ID:harshithanaiduk,项目名称:ideconnect_2016,代码行数:55,代码来源:AdminController.php


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