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


PHP Question::with方法代码示例

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


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

示例1: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $Q = Question::with('questionnaire')->find($id);
     if (is_null($Q)) {
         return Response::json(['error' => 'no such question found'], 404);
     }
     return Response::json($Q, 200);
 }
开发者ID:mymedialab,项目名称:listenings,代码行数:14,代码来源:QuestionController.php

示例2: postAdminEditQuestions

 public function postAdminEditQuestions($question_id)
 {
     $question = Question::with('answers')->findOrFail($question_id);
     $question->text = Input::get('question');
     $question->correct_answer_id = Input::get('correct_answer');
     foreach ($question->answers as $answer) {
         $answer->text = Input::get('answers')[$answer->id];
         $answer->save();
     }
     if ($question->save()) {
         return Redirect::route('getAdminEditQuestions', $question_id)->with('success', 'You have edit question successfully.');
     } else {
         return Redirect::route('getAdminEditQuestions', $question_id)->with('fail', 'Error. Please try again later.');
     }
 }
开发者ID:EmilAleksandrov,项目名称:cinegrand-game,代码行数:15,代码来源:AdminController.php

示例3: questions

 public function questions()
 {
     if (Auth::user()->correct_answers_count < 3) {
         $result = Question::where('type', 0)->get();
     } else {
         if (Auth::user()->correct_answers_count == 3) {
             $result = Question::where('type', 1)->get();
         } else {
             return Redirect::to('confirme');
         }
     }
     $rand = rand(0, count($result) - 1);
     $question = Question::with('answers')->find($result[$rand]->id);
     return View::make('user.questions')->with('question', $question);
 }
开发者ID:EmilAleksandrov,项目名称:cinegrand-game,代码行数:15,代码来源:HomeController.php

示例4: function

    });
    $app->get('/:id/questions', function ($id) use($app) {
        $ids = explode(';', $id);
        $questions = Question::whereIn('set_id', $ids)->get();
        $questions->load('answers');
        $res = $app->response();
        $res['Content-Type'] = 'application/json';
        $res->body($questions);
    });
});
$app->group('/question(s)', function () use($app) {
    $app->get('/', function () use($app) {
        $questions = Question::with('answers')->get();
        $res = $app->response();
        $res['Content-Type'] = 'application/json';
        $res->body($questions);
    });
    $app->get('/:id', function ($id) use($app) {
        $question = Question::with('answers')->find($id);
        $res = $app->response();
        $res['Content-Type'] = 'application/json';
        $res->body($question);
    });
    $app->get('/:id/answers', function ($id) use($app) {
        $answers = Question::find($id)->answers;
        $res = $app->response();
        $res['Content-Type'] = 'application/json';
        $res->body($answers);
    });
});
$app->run();
开发者ID:guillepb,项目名称:empollon,代码行数:31,代码来源:index.php

示例5: getDetails

 /**
  * Details page
  **/
 public function getDetails($id, $title)
 {
     //First, let's try to find the question:
     $question = Question::with('users', 'tags', 'answers')->find($id);
     if ($question) {
         //We should increase the "viewed" amount
         $question->update(array('viewed' => $question->viewed + 1));
         return View::make('qa.details')->with('title', $question->title)->with('question', $question);
     } else {
         return Redirect::route('index')->with('error', 'Question not found');
     }
 }
开发者ID:suchayj,项目名称:easymanage,代码行数:15,代码来源:QuestionController.php


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