Modified loading questions on a section

This commit is contained in:
Gregorio Chiko Putra 2018-01-16 08:46:33 +07:00
parent 17cba5192a
commit 9248326688
2 changed files with 5 additions and 6 deletions

View File

@ -19,13 +19,11 @@ class SectionQuestionController extends Controller
*/
public function index($section)
{
$question = Section::find($section)
->questions()->paginate(1);
$questions = Section::find($section)
->questions()
->orderBy('number', 'asc')->get();
return $this->response
->paginator($question, new QuestionTransformer, ['key' => 'questions']);
// return QuestionTransformer::collection($questions);
return $this->response->collection($questions, new QuestionTransformer);
}
/**

View File

@ -27,6 +27,7 @@ class QuestionTransformer extends TransformerAbstract
'questionType' => $model->question_type,
'choices' => $model->choices,
'creator' => new UserResource($model->creator),
'answers' => $model->answers,
'links' => [
'relatedTo' => route('questions.index')
]