protected function PerformTest() { // Create a QuestionRequest object (using the full domain name for // Stack Apps - might as well test that too) $request = new QuestionRequest('stackapps.com'); $this->CompareOutput($request->URL(), 'http://api.stackexchange.com/2.0/questions?filter=' . urlencode(Filter::$default_filter) . '&key=' . urlencode(API::$key) . '&site=stackapps.com'); // Now fetch only questions with no answers $request->NoAnswers(); $this->CompareOutput($request->URL(), 'http://api.stackexchange.com/2.0/questions/no-answers?filter=' . urlencode(Filter::$default_filter) . '&key=' . urlencode(API::$key) . '&site=stackapps.com'); // Reduce this list down to questions that have votes > 8 $request->SortByVotes()->Min(8); $this->CompareOutput($request->URL(), 'http://api.stackexchange.com/2.0/questions/no-answers?filter=' . urlencode(Filter::$default_filter) . '&key=' . urlencode(API::$key) . '&site=stackapps.com&sort=votes&min=8'); // Execute the request to obtain a paged response $response = $request->Exec(); // Make sure all questions have no answers and a score >= 18 while ($item = $response->Fetch(FALSE)) { if ($item['score'] < 8 || $item['answer_count']) { throw new Exception("Question #{$item['question_id']} does not match the specified criterion."); } } }
/** * \param $id either a question ID or an array of question IDs * \return a QuestionRequest object * * This method is used for retrieving questions from the site. Simply chain * methods to the return value of this method and then call Exec() to issue * the request and receive a response object. * * <b>Example:</b> <kbd>$response = $site->Questions()->SortByVotes()->Min(100)->Exec();</kbd> */ public function Questions($id = null) { $request = new QuestionRequest($this->api_domain); // Add the IDs if supplied if ($id !== null) { $request->ID($id); } return $request; }
public function store(QuestionRequest $request) { $request->merge(['ip_address' => $this->request->getClientIp(true)]); $question = Question::create($request->all()); return redirect('quotes/lists'); }