Modified loading questions on a section
This commit is contained in:
parent
17cba5192a
commit
9248326688
@ -19,13 +19,11 @@ class SectionQuestionController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index($section)
|
public function index($section)
|
||||||
{
|
{
|
||||||
$question = Section::find($section)
|
$questions = Section::find($section)
|
||||||
->questions()->paginate(1);
|
->questions()
|
||||||
|
->orderBy('number', 'asc')->get();
|
||||||
|
|
||||||
return $this->response
|
return $this->response->collection($questions, new QuestionTransformer);
|
||||||
->paginator($question, new QuestionTransformer, ['key' => 'questions']);
|
|
||||||
|
|
||||||
// return QuestionTransformer::collection($questions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +27,7 @@ class QuestionTransformer extends TransformerAbstract
|
|||||||
'questionType' => $model->question_type,
|
'questionType' => $model->question_type,
|
||||||
'choices' => $model->choices,
|
'choices' => $model->choices,
|
||||||
'creator' => new UserResource($model->creator),
|
'creator' => new UserResource($model->creator),
|
||||||
|
'answers' => $model->answers,
|
||||||
'links' => [
|
'links' => [
|
||||||
'relatedTo' => route('questions.index')
|
'relatedTo' => route('questions.index')
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user